From 2e816a4947aaf0aef1d06b61ce79e76c384f28e8 Mon Sep 17 00:00:00 2001 From: Taco de Wolff Date: Fri, 20 Oct 2023 09:47:44 -0300 Subject: [PATCH] XML: keep unquoted attribute values untouched, fixes #611 --- xml/xml.go | 2 +- xml/xml_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/xml/xml.go b/xml/xml.go index 47ca02aa37..80a82d3f5e 100644 --- a/xml/xml.go +++ b/xml/xml.go @@ -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] diff --git a/xml/xml_test.go b/xml/xml_test.go index d8b01a7f9d..aa3dbc856e 100644 --- a/xml/xml_test.go +++ b/xml/xml_test.go @@ -28,6 +28,7 @@ func TestXML(t *testing.T) { {``, ``}, {``, ``}, {``, ``}, + {``, ``}, {"", ``}, {``, ``}, {``, ``},