diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 646a9bd..b5adab1 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -143,6 +143,9 @@ func FormatXml(reader io.Reader, writer io.Writer, indent string, colors int) er _, _ = fmt.Fprint(writer, tagColor(">")) startTagClosed = true } + if hasContent && (strings.Contains(str, "&") || strings.Contains(str, "<")) { + str = "" + } _, _ = fmt.Fprint(writer, str) case xml.Comment: if !startTagClosed { diff --git a/internal/utils/utils_test.go b/internal/utils/utils_test.go index a0da201..8e1c770 100644 --- a/internal/utils/utils_test.go +++ b/internal/utils/utils_test.go @@ -37,6 +37,7 @@ func TestFormatXml(t *testing.T) { "unformatted12.xml": "formatted12.xml", "unformatted13.xml": "formatted13.xml", "unformatted14.xml": "formatted14.xml", + "unformatted15.xml": "formatted15.xml", } for unformattedFile, expectedFile := range files { diff --git a/test/data/xml/formatted15.xml b/test/data/xml/formatted15.xml new file mode 100644 index 0000000..ac743bd --- /dev/null +++ b/test/data/xml/formatted15.xml @@ -0,0 +1,2 @@ + + diff --git a/test/data/xml/unformatted15.xml b/test/data/xml/unformatted15.xml new file mode 100644 index 0000000..0e3f4ed --- /dev/null +++ b/test/data/xml/unformatted15.xml @@ -0,0 +1 @@ +