ref: 111344113bf8c16ae45528d67ff408da15961727
parent: 4855c186d8f05e5e1b0f681b4aa6482a033df241
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Mon Sep 28 18:17:36 EDT 2020
publisher: Fix writeStats with quote inside quotes Fixes #7746
--- a/publisher/htmlElementsCollector.go
+++ b/publisher/htmlElementsCollector.go
@@ -67,7 +67,9 @@
isCollecting bool
dropValue bool
- inQuote bool
+
+ inQuote bool
+ quoteValue byte
}
func (w *cssClassCollectorWriter) Write(p []byte) (n int, err error) {
@@ -165,7 +167,12 @@
func (c *cssClassCollectorWriter) toggleIfQuote(b byte) {
if isQuote(b) {
- c.inQuote = !c.inQuote
+ if c.inQuote && b == c.quoteValue {
+ c.inQuote = false
+ } else if !c.inQuote {
+ c.inQuote = true
+ c.quoteValue = b
+ }
}
}
--- a/publisher/htmlElementsCollector_test.go
+++ b/publisher/htmlElementsCollector_test.go
@@ -87,6 +87,8 @@
{"Alpine transition 1", `<div x-transition:enter-start="opacity-0 transform mobile:-translate-x-8 sm:-translate-y-8">`, f("div", "mobile:-translate-x-8 opacity-0 sm:-translate-y-8 transform", "")},
{"Vue bind", `<div v-bind:class="{ active: isActive }"></div>`, f("div", "active", "")},
+ // https://github.com/gohugoio/hugo/issues/7746
+ {"Apostrophe inside attribute value", `<a class="missingclass" title="Plus d'information">my text</a><div></div>`, f("a div", "missingclass", "")},
} {
c.Run(test.name, func(c *qt.C) {
w := newHTMLElementsCollectorWriter(newHTMLElementsCollector())