Skip to content

Commit

Permalink
Fix panic when selector ends with '('.
Browse files Browse the repository at this point in the history
Found with go-fuzz.
  • Loading branch information
andybalholm committed Jul 30, 2015
1 parent 893e27f commit 3ad29d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ func (p *parser) parseAttributeSelector() (Selector, error) {

var expectedParenthesis = errors.New("expected '(' but didn't find it")
var expectedClosingParenthesis = errors.New("expected ')' but didn't find it")
var unmatchedParenthesis = errors.New("unmatched '('")

// parsePseudoclassSelector parses a pseudoclass selector like :not(p).
func (p *parser) parsePseudoclassSelector() (Selector, error) {
Expand Down Expand Up @@ -457,6 +458,9 @@ func (p *parser) parsePseudoclassSelector() (Selector, error) {
if !p.consumeParenthesis() {
return nil, expectedParenthesis
}
if p.i == len(p.s) {
return nil, unmatchedParenthesis
}
var val string
switch p.s[p.i] {
case '\'', '"':
Expand Down

0 comments on commit 3ad29d1

Please sign in to comment.