Skip to content

Commit

Permalink
Merge pull request aymerick#4 from chris-ramon/malformed-syntax-impro…
Browse files Browse the repository at this point in the history
…vement

malformed syntax improvement
  • Loading branch information
chris-ramon committed Jun 3, 2016
2 parents 8fb9598 + ec661e3 commit f346305
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
5 changes: 2 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,8 @@ func (parser *Parser) parseQualifiedRule() (*css.Rule, error) {
// finished
break
} else if parser.tokenChar(";") {
parser.shiftToken()
// finished
break
errMsg := fmt.Sprintf("Unexpected ; character: %s", parser.nextToken().String())
return result, errors.New(errMsg)
} else {
// parse prelude
prelude, err, tokens := parser.parsePrelude()
Expand Down
20 changes: 3 additions & 17 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,22 +861,8 @@ func TestComments(t *testing.T) {

func TestInfiniteLoop(t *testing.T) {
input := "{;}"

expectedRule := &css.Rule{
Kind: css.QualifiedRule,
Prelude: "",
Selectors: []*css.Selector{
{
Value: "",
Line: 0,
Column: 0,
},
},
Declarations: []*css.Declaration{},
_, err := Parse(input)
if err == nil {
t.Fatal("Expected an error got nil")
}

stylesheet := MustParse(t, input, 1)
rule := stylesheet.Rules[0]

MustEqualRule(t, rule, expectedRule)
}

0 comments on commit f346305

Please sign in to comment.