From b29611cbd04eadade5478d4d8715067bce602076 Mon Sep 17 00:00:00 2001 From: Alexei Yuzhakov Date: Sat, 26 Oct 2024 18:57:58 +0100 Subject: [PATCH] Fix #103: Enforce UTF-8 encoding even if UTF-16 is misdeclared --- internal/utils/utils.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/utils/utils.go b/internal/utils/utils.go index c4ebfb9..ed6b003 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -59,6 +59,9 @@ func FormatXml(reader io.Reader, writer io.Writer, indent string, colors int) er decoder := xml.NewDecoder(reader) decoder.Strict = false decoder.CharsetReader = func(charset string, input io.Reader) (io.Reader, error) { + if strings.ToLower(charset) == "utf-16" { + charset = "utf-8" + } e, err := ianaindex.MIME.Encoding(charset) if err != nil { return nil, err