diff options
Diffstat (limited to 'vendor/github.com/tdewolff/parse/v2/html/lex.go')
-rw-r--r-- | vendor/github.com/tdewolff/parse/v2/html/lex.go | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/vendor/github.com/tdewolff/parse/v2/html/lex.go b/vendor/github.com/tdewolff/parse/v2/html/lex.go index e3cb9bd04..c000edccc 100644 --- a/vendor/github.com/tdewolff/parse/v2/html/lex.go +++ b/vendor/github.com/tdewolff/parse/v2/html/lex.go @@ -166,6 +166,7 @@ func (l *Lexer) Next() (TokenType, []byte) { isEndTag := c == '/' && l.r.Peek(2) != '>' && (l.r.Peek(2) != 0 || l.r.PeekErr(2) == nil) if !isEndTag && (c < 'a' || 'z' < c) && (c < 'A' || 'Z' < c) && c != '!' && c != '?' { // not a tag + l.r.Move(1) } else if 0 < l.r.Pos() { // return currently buffered texttoken so that we can return tag next iteration l.text = l.r.Shift() @@ -202,8 +203,9 @@ func (l *Lexer) Next() (TokenType, []byte) { return TextToken, l.text } return ErrorToken, nil + } else { + l.r.Move(1) } - l.r.Move(1) } } @@ -539,19 +541,19 @@ func (l *Lexer) shiftXML(rawTag Hash) []byte { func (l *Lexer) moveTemplate() { for { - if c := l.r.Peek(0); l.at(l.tmplEnd...) || c == 0 && l.r.Err() != nil { - if c != 0 { - l.r.Move(len(l.tmplEnd)) - } - break + if c := l.r.Peek(0); c == 0 && l.r.Err() != nil { + return + } else if l.at(l.tmplEnd...) { + l.r.Move(len(l.tmplEnd)) + return } else if c == '"' || c == '\'' { l.r.Move(1) escape := false for { - if c2 := l.r.Peek(0); !escape && c2 == c || c2 == 0 && l.r.Err() != nil { - if c2 != 0 { - l.r.Move(1) - } + if c2 := l.r.Peek(0); c2 == 0 && l.r.Err() != nil { + return + } else if !escape && c2 == c { + l.r.Move(1) break } else if c2 == '\\' { escape = !escape |