Skip to content

Commit

Permalink
Remove conflict between ReadSettings values
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
beevik committed Jul 18, 2024
1 parent c40669c commit 8965a48
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions etree.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ type WriteSettings struct {

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

// AttrSingleQuote causes attributes to use single quotes (attr='example')
Expand Down Expand Up @@ -1463,7 +1464,7 @@ func (a *Attr) WriteTo(w Writer, s *WriteSettings) {
w.WriteString(`="`)
}
var m escapeMode
if s.CanonicalAttrVal {
if s.CanonicalAttrVal && !s.AttrSingleQuote {
m = escapeCanonicalAttr
} else {
m = escapeNormal
Expand Down

0 comments on commit 8965a48

Please sign in to comment.