Skip to content

Commit

Permalink
XML: keep unquoted attribute values untouched, fixes #611
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Oct 20, 2023
1 parent 76935f3 commit 2e816a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion xml/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
w.Write(t.Text)
w.Write(isBytes)

if len(t.AttrVal) < 2 {
if len(t.AttrVal) < 2 || t.AttrVal[0] != '"' || t.AttrVal[len(t.AttrVal)-1] != '"' {
w.Write(t.AttrVal)
} else {
val := t.AttrVal[1 : len(t.AttrVal)-1]
Expand Down
1 change: 1 addition & 0 deletions xml/xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestXML(t *testing.T) {
{`<x a="b"></x>`, `<x a="b"/>`},
{`<x a=""></x>`, `<x a=""/>`},
{`<x a=a></x>`, `<x a=a/>`},
{`<x a=foo></x>`, `<x a=foo/>`},
{"<x a=\" a \n\r\t b \"/>", `<x a=" a b "/>`},
{`<x a="&apos;b&quot;"></x>`, `<x a="'b&#34;"/>`},
{`<x a="&quot;&quot;'"></x>`, `<x a='""&#39;'/>`},
Expand Down

0 comments on commit 2e816a4

Please sign in to comment.