-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix lexer.errInvalidToken panic #184
Conversation
78c5fe0
to
f8c45dd
Compare
f8c45dd
to
30bdb17
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, except some minor comments.
jlexer/lexer.go
Outdated
isValid, hasEscapes, length := findStringLen(data) | ||
if !isValid { | ||
r.pos += length | ||
r.errParse("missing trailing string literal") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"unterminated string literal", or "missing trailing quote char". A literal is the whole string with opening/ending quote chars.
jlexer/lexer_test.go
Outdated
for _, test := range []struct { | ||
data []byte | ||
}{ | ||
{data: []byte(`"sting without trailing literal`)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, "... trailing quote"
jlexer/lexer_test.go
Outdated
l := Lexer{Data: test.data} | ||
l.fetchString() | ||
if l.pos > len(l.Data) { | ||
t.Errorf("pos should not be greater than length of Data") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please indicate what test case failed, e.g.:
t.Errorf("fetchString(%s): pos should not be greater than length of Data", test.data)
Same goes for the error below.
Fixes panic during processing jlexer.Data with the same length and capacity