Skip to content

Commit

Permalink
Fix #103: Enforce UTF-8 encoding even if UTF-16 is misdeclared
Browse files Browse the repository at this point in the history
  • Loading branch information
sibprogrammer committed Oct 26, 2024
1 parent 685bd06 commit b29611c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b29611c

Please sign in to comment.