diff options
author | 2024-02-19 07:23:08 +0000 | |
---|---|---|
committer | 2024-02-19 07:23:08 +0000 | |
commit | 30f6e6c7fe8a9264ba5d4e30d1e858cdb90b35b0 (patch) | |
tree | 069af96b21d9c76651e9fdd1bf0e9761c33dc737 /vendor/github.com/tdewolff/parse/v2/html/util.go | |
parent | [bugfix] Refactor parse mention, fix local mention bug (#2657) (diff) | |
download | gotosocial-30f6e6c7fe8a9264ba5d4e30d1e858cdb90b35b0.tar.xz |
[chore]: Bump github.com/tdewolff/minify/v2 from 2.20.16 to 2.20.17 (#2661)
Diffstat (limited to 'vendor/github.com/tdewolff/parse/v2/html/util.go')
-rw-r--r-- | vendor/github.com/tdewolff/parse/v2/html/util.go | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/vendor/github.com/tdewolff/parse/v2/html/util.go b/vendor/github.com/tdewolff/parse/v2/html/util.go index 0dbd52ca0..1bebd6b06 100644 --- a/vendor/github.com/tdewolff/parse/v2/html/util.go +++ b/vendor/github.com/tdewolff/parse/v2/html/util.go @@ -6,7 +6,7 @@ var ( ) // EscapeAttrVal returns the escaped attribute value bytes with quotes. Either single or double quotes are used, whichever is shorter. If there are no quotes present in the value and the value is in HTML (not XML), it will return the value without quotes. -func EscapeAttrVal(buf *[]byte, b []byte, origQuote byte, mustQuote, isXML bool) []byte { +func EscapeAttrVal(buf *[]byte, b []byte, origQuote byte, mustQuote bool) []byte { singles := 0 doubles := 0 unquoted := true @@ -20,9 +20,9 @@ func EscapeAttrVal(buf *[]byte, b []byte, origQuote byte, mustQuote, isXML bool) } } } - if unquoted && (!mustQuote || origQuote == 0) && !isXML { + if unquoted && (!mustQuote || origQuote == 0) { return b - } else if singles == 0 && origQuote == '\'' && !isXML || doubles == 0 && origQuote == '"' { + } else if singles == 0 && origQuote == '\'' || doubles == 0 && origQuote == '"' { if len(b)+2 > cap(*buf) { *buf = make([]byte, 0, len(b)+2) } @@ -36,14 +36,10 @@ func EscapeAttrVal(buf *[]byte, b []byte, origQuote byte, mustQuote, isXML bool) n := len(b) + 2 var quote byte var escapedQuote []byte - if singles >= doubles || isXML { + if singles > doubles || singles == doubles && origQuote != '\'' { n += doubles * 4 quote = '"' escapedQuote = doubleQuoteEntityBytes - if singles == doubles && origQuote == '\'' && !isXML { - quote = '\'' - escapedQuote = singleQuoteEntityBytes - } } else { n += singles * 4 quote = '\'' |