diff --git a/go.mod b/go.mod index 1ba67e86fb..abccc84717 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,6 @@ require ( github.com/fsnotify/fsnotify v1.5.3 github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 github.com/spf13/pflag v1.0.5 - github.com/tdewolff/parse/v2 v2.5.30 + github.com/tdewolff/parse/v2 v2.5.31 github.com/tdewolff/test v1.0.6 ) diff --git a/go.sum b/go.sum index 62ecc9fa40..4780be7428 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 h1:JAEbJn3j/FrhdWA9jW8 github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/tdewolff/parse/v2 v2.5.30 h1:8pcdUXgBWsDKkvnxfTHSAj3pANBs8japx6vLqozJ+yg= -github.com/tdewolff/parse/v2 v2.5.30/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= +github.com/tdewolff/parse/v2 v2.5.31 h1:PrJN/trWTUYaYxg7jRpKnKXpBK4kBjT9rAFhFAh2Lus= +github.com/tdewolff/parse/v2 v2.5.31/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho= github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4= github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= diff --git a/html/html.go b/html/html.go index 96a3976aae..c923b0e70c 100644 --- a/html/html.go +++ b/html/html.go @@ -484,9 +484,10 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st isXML := attr.Hash == Vocab || attr.Hash == Typeof || attr.Hash == Property || attr.Hash == Resource || attr.Hash == Prefix || attr.Hash == Content || attr.Hash == About || attr.Hash == Rev || attr.Hash == Datatype || attr.Hash == Inlist // no quotes if possible, else prefer single or double depending on which occurs more often in value - quote := attr.Data[len(attr.Data)-1] - if quote != '\'' && quote != '"' { - quote = 0 + var quote byte + + if 0 < len(attr.Data) && (attr.Data[len(attr.Data)-1] == '\'' || attr.Data[len(attr.Data)-1] == '"') { + quote = attr.Data[len(attr.Data)-1] } val = html.EscapeAttrVal(&attrByteBuffer, val, quote, o.KeepQuotes, isXML) w.Write(val)