diff options
| author | 2025-04-01 16:21:59 +0000 | |
|---|---|---|
| committer | 2025-04-01 18:21:59 +0200 | |
| commit | b0873972ecb6d9977a36898d8281649d38c17df7 (patch) | |
| tree | 1b0eb8a89c99058d443e6550e4dfa3ba347804a7 /vendor/golang.org/x/net/html/token.go | |
| parent | update modernc.org/sqlite to v1.37.0-concurrrency-workaround (#3958) (diff) | |
| download | gotosocial-b0873972ecb6d9977a36898d8281649d38c17df7.tar.xz | |
[chore] bump golang.org/x/net@v0.38.0, github.com/gin-contrib/cors@v1.7.4, github.com/spf13/viper@v1.20.1, github.com/tdewolff/minify/v2@v2.22.4 (#3959)
Diffstat (limited to 'vendor/golang.org/x/net/html/token.go')
| -rw-r--r-- | vendor/golang.org/x/net/html/token.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/vendor/golang.org/x/net/html/token.go b/vendor/golang.org/x/net/html/token.go index 3c57880d6..6598c1f7b 100644 --- a/vendor/golang.org/x/net/html/token.go +++ b/vendor/golang.org/x/net/html/token.go @@ -839,8 +839,22 @@ func (z *Tokenizer) readStartTag() TokenType { if raw { z.rawTag = strings.ToLower(string(z.buf[z.data.start:z.data.end])) } - // Look for a self-closing token like "<br/>". - if z.err == nil && z.buf[z.raw.end-2] == '/' { + // Look for a self-closing token (e.g. <br/>). + // + // Originally, we did this by just checking that the last character of the + // tag (ignoring the closing bracket) was a solidus (/) character, but this + // is not always accurate. + // + // We need to be careful that we don't misinterpret a non-self-closing tag + // as self-closing, as can happen if the tag contains unquoted attribute + // values (i.e. <p a=/>). + // + // To avoid this, we check that the last non-bracket character of the tag + // (z.raw.end-2) isn't the same character as the last non-quote character of + // the last attribute of the tag (z.pendingAttr[1].end-1), if the tag has + // attributes. + nAttrs := len(z.attr) + if z.err == nil && z.buf[z.raw.end-2] == '/' && (nAttrs == 0 || z.raw.end-2 != z.attr[nAttrs-1][1].end-1) { return SelfClosingTagToken } return StartTagToken |
