Skip to content

Commit

Permalink
fix space required after regex operator
Browse files Browse the repository at this point in the history
Fix for this issue: influxdata/influxdb#9058
Removed p.consumeWhitespace() when parsing expression and added a test
stop-start committed Nov 10, 2017

Verified

This commit was signed with the committer’s verified signature.
rouault Even Rouault
1 parent 3921ab7 commit 0554df2
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion parser.go
Original file line number Diff line number Diff line change
@@ -2549,7 +2549,6 @@ func (p *Parser) ParseExpr() (Expr, error) {
var rhs Expr
if IsRegexOp(op) {
// RHS of a regex operator must be a regular expression.
p.consumeWhitespace()
if rhs, err = p.parseRegex(); err != nil {
return nil, err
}
10 changes: 10 additions & 0 deletions parser_test.go
Original file line number Diff line number Diff line change
@@ -3634,6 +3634,16 @@ func TestParser_ParseExpr(t *testing.T) {
},
},

// Binary expression with quoted '/' regex without space around operator. Influxdb #9058
{
s: `url=~/http\:\/\/www\.example\.com/`,
expr: &influxql.BinaryExpr{
Op: influxql.EQREGEX,
LHS: &influxql.VarRef{Val: "url"},
RHS: &influxql.RegexLiteral{Val: regexp.MustCompile(`http\://www\.example\.com`)},
},
},

// Complex binary expression.
{
s: `value + 3 < 30 AND 1 + 2 OR true`,

0 comments on commit 0554df2

Please sign in to comment.