Skip to content

Commit 8965a48

Browse files
committed
Remove conflict between ReadSettings values
In ReadSettings, when AttrSingleQuote is true, CanonicalAttrVal is now forced to be false. This resolves a character escaping conflict that arose due to the lack of apostrophe-escaping with CanonicalAttrVal.
1 parent c40669c commit 8965a48

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

etree.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ type WriteSettings struct {
113113

114114
// CanonicalAttrVal forces the production of XML character references for
115115
// attribute value characters &, < and ". If false, XML character
116-
// references are also produced for > and '. Default: false.
116+
// references are also produced for > and '. Ignored when AttrSingleQuote
117+
// is true. Default: false.
117118
CanonicalAttrVal bool
118119

119120
// AttrSingleQuote causes attributes to use single quotes (attr='example')
@@ -1463,7 +1464,7 @@ func (a *Attr) WriteTo(w Writer, s *WriteSettings) {
14631464
w.WriteString(`="`)
14641465
}
14651466
var m escapeMode
1466-
if s.CanonicalAttrVal {
1467+
if s.CanonicalAttrVal && !s.AttrSingleQuote {
14671468
m = escapeCanonicalAttr
14681469
} else {
14691470
m = escapeNormal

0 commit comments

Comments
 (0)