summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/net/html/token.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-03-09 21:39:06 +0100
committerGitHub <noreply@github.com>2023-03-09 21:39:06 +0100
commit57ce19150f38842cdf44370b358881dbb83fb20e (patch)
tree42512063df92e51b69b9d1e6fb0b247c3f276da4 /vendor/golang.org/x/net/html/token.go
parent24f6747516a9a80f82068656df50b3972928ba56 (diff)
downloadmatterbridge-msglm-57ce19150f38842cdf44370b358881dbb83fb20e.tar.gz
matterbridge-msglm-57ce19150f38842cdf44370b358881dbb83fb20e.tar.bz2
matterbridge-msglm-57ce19150f38842cdf44370b358881dbb83fb20e.zip
Bump golang.org/x/net from 0.5.0 to 0.7.0 (#2003)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.5.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/compare/v0.5.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/golang.org/x/net/html/token.go')
-rw-r--r--vendor/golang.org/x/net/html/token.go49
1 files changed, 41 insertions, 8 deletions
diff --git a/vendor/golang.org/x/net/html/token.go b/vendor/golang.org/x/net/html/token.go
index ae24a6fd..50f7c6aa 100644
--- a/vendor/golang.org/x/net/html/token.go
+++ b/vendor/golang.org/x/net/html/token.go
@@ -598,6 +598,11 @@ scriptDataDoubleEscapeEnd:
// readComment reads the next comment token starting with "<!--". The opening
// "<!--" has already been consumed.
func (z *Tokenizer) readComment() {
+ // When modifying this function, consider manually increasing the suffixLen
+ // constant in func TestComments, from 6 to e.g. 9 or more. That increase
+ // should only be temporary, not committed, as it exponentially affects the
+ // test running time.
+
z.data.start = z.raw.end
defer func() {
if z.data.end < z.data.start {
@@ -611,11 +616,7 @@ func (z *Tokenizer) readComment() {
for {
c := z.readByte()
if z.err != nil {
- // Ignore up to two dashes at EOF.
- if dashCount > 2 {
- dashCount = 2
- }
- z.data.end = z.raw.end - dashCount
+ z.data.end = z.calculateAbruptCommentDataEnd()
return
}
switch c {
@@ -631,12 +632,15 @@ func (z *Tokenizer) readComment() {
if dashCount >= 2 {
c = z.readByte()
if z.err != nil {
- z.data.end = z.raw.end
+ z.data.end = z.calculateAbruptCommentDataEnd()
return
- }
- if c == '>' {
+ } else if c == '>' {
z.data.end = z.raw.end - len("--!>")
return
+ } else if c == '-' {
+ dashCount = 1
+ beginning = false
+ continue
}
}
}
@@ -645,6 +649,35 @@ func (z *Tokenizer) readComment() {
}
}
+func (z *Tokenizer) calculateAbruptCommentDataEnd() int {
+ raw := z.Raw()
+ const prefixLen = len("<!--")
+ if len(raw) >= prefixLen {
+ raw = raw[prefixLen:]
+ if hasSuffix(raw, "--!") {
+ return z.raw.end - 3
+ } else if hasSuffix(raw, "--") {
+ return z.raw.end - 2
+ } else if hasSuffix(raw, "-") {
+ return z.raw.end - 1
+ }
+ }
+ return z.raw.end
+}
+
+func hasSuffix(b []byte, suffix string) bool {
+ if len(b) < len(suffix) {
+ return false
+ }
+ b = b[len(b)-len(suffix):]
+ for i := range b {
+ if b[i] != suffix[i] {
+ return false
+ }
+ }
+ return true
+}
+
// readUntilCloseAngle reads until the next ">".
func (z *Tokenizer) readUntilCloseAngle() {
z.data.start = z.raw.end