Skip to content

Commit

Permalink
Merge pull request influxdata#1780 from influxdb/1768
Browse files Browse the repository at this point in the history
malformed identifiers get through
  • Loading branch information
rothrock committed Feb 27, 2015
2 parents db91f0c + bcad98c commit 325f613
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion influxql/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (s *Scanner) scanIdent() (tok Token, pos Pos, lit string) {
} else if ch == '.' {
buf.WriteRune(ch)
} else if ch == '"' {
if tok0, pos0, lit0 := s.scanString(); tok == BADSTRING || tok == BADESCAPE {
if tok0, pos0, lit0 := s.scanString(); tok0 == BADSTRING || tok0 == BADESCAPE {
return tok0, pos0, lit0
} else {
_ = buf.WriteByte('"')
Expand Down
5 changes: 5 additions & 0 deletions influxql/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func TestScanner_Scan(t *testing.T) {
{s: `foo`, tok: influxql.IDENT, lit: `foo`},
{s: `Zx12_3U_-`, tok: influxql.IDENT, lit: `Zx12_3U_`},
{s: `"foo".bar`, tok: influxql.IDENT, lit: `"foo".bar`},
{s: `"foo\\bar"`, tok: influxql.IDENT, lit: `"foo\bar"`},
{s: `"foo\bar"`, tok: influxql.BADESCAPE, lit: `\b`, pos: influxql.Pos{Line: 0, Char: 5}},
{s: `"foo\"bar\""`, tok: influxql.IDENT, lit: `"foo"bar""`},
{s: `test"`, tok: influxql.BADSTRING, lit: "", pos: influxql.Pos{Line: 0, Char: 3}},
{s: `"test`, tok: influxql.BADSTRING, lit: `test`},

{s: `true`, tok: influxql.TRUE},
{s: `false`, tok: influxql.FALSE},
Expand Down
2 changes: 2 additions & 0 deletions influxql/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ var tokens = [...]string{
NUMBER: "NUMBER",
DURATION_VAL: "DURATION_VAL",
STRING: "STRING",
BADSTRING: "BADSTRING",
BADESCAPE: "BADESCAPE",
TRUE: "TRUE",
FALSE: "FALSE",

Expand Down

0 comments on commit 325f613

Please sign in to comment.