Skip to content

Commit

Permalink
orbis: fix escape binary num check
Browse files Browse the repository at this point in the history
  • Loading branch information
lithdew committed May 25, 2020
1 parent 4027216 commit 47a7361
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions orbis/constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func isBinRune(r rune) bool {
}

func TestConstraint(t *testing.T) {
q := `"\xffg" | 0.123e4 & "yes"`
q := `"\377" | 0.123e4 & "yes"`

bc := 0 // byte count
cc := 0 // char count
Expand Down Expand Up @@ -87,16 +87,13 @@ func TestConstraint(t *testing.T) {
tokens := make([]token, 0, len(q)/2)

lexEscapeChar := func(quote rune) {
switch next() {
r := next()

switch r {
case eof:
panic("got eof while parsing escape literal")
case quote, 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\':
// ignore
case '0', '1', '2', '3', '4', '5', '6', '7':
for n := 0; n < 2; n++ {
r := next()
if !isBinRune(r) || r == eof {
panic("bad 8")
}
}
case 'x':
for n := 0; n < 2; n++ {
r := lower(next())
Expand All @@ -118,10 +115,16 @@ func TestConstraint(t *testing.T) {
panic("bad 64")
}
}
case eof:
panic("got eof while parsing escape literal")
default:
panic("unknown escape literal")
if !isBinRune(r) || r == eof {
panic("bad 8")
}
for n := 0; n < 2; n++ {
r = next()
if !isBinRune(r) || r == eof {
panic("bad 8")
}
}
}
}

Expand Down

0 comments on commit 47a7361

Please sign in to comment.