Skip to content
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

Incorrect parsing of regex containing '/' #3429

Closed
dawbs opened this issue Jul 22, 2015 · 5 comments
Closed

Incorrect parsing of regex containing '/' #3429

dawbs opened this issue Jul 22, 2015 · 5 comments

Comments

@dawbs
Copy link
Contributor

dawbs commented Jul 22, 2015

Running official nightly from 0.9.2 downloaded 22 Jul 2015

when using a regex where clause, a regex containing the '/' character will be truncated even if it is properly escaped. This is problematic when you have used a URL as a tag

(likely any clause after having a bit of a look at the code)

The following query fails:

SELECT * from measurement WHERE url =~ /http\:\/\/www.akamai\.com/

Escaping the escaping backslash as below appears to get around the problem, but is then not a valid go regex anymore

SELECT * from measurement WHERE url =~ /http\:\\/\\/www.akamai\.com/
@dawbs
Copy link
Contributor Author

dawbs commented Jul 23, 2015

Test case:
create database

curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

write data

curl -d 'test,url=http://www.akamai.com value=404' http://localhost:8086/write?db=mydb
curl -d 'test,url=https://influxdb.com value=418' http://localhost:8086/write?db=mydb

Query using Go regex - Does not produce expected output:

curl -G http://localhost:8086/query  --data-urlencode 'db=mydb' --data-urlencode 'q=SELECT * FROM test WHERE url =~ /http\:\/\/www.akamai\.com/'

Query using double escaped regex - does produce expected output:

curl -G http://localhost:8086/query  --data-urlencode 'db=mydb' --data-urlencode 'q=SELECT * FROM test WHERE url =~ /http\:\\/\\/www.akamai\.com/'

I have written some failing go tests and am having a bit of a look, but still getting my head around the project

@dawbs
Copy link
Contributor Author

dawbs commented Jul 23, 2015

And further, the edge case seems to be two // characters

Either one of the following two queries DO produce the correct output:

SELECT * FROM test WHERE url =~ /http\:\\/\/www.akamai\.com/
SELECT * FROM test WHERE url =~ /http\:\/\\/www.akamai\.com/

@beckettsean
Copy link
Contributor

Thanks for the excellent bug characterization, @dawbs.

@dgnorton is this a quick fix, you think?

@dawbs
Copy link
Contributor Author

dawbs commented Jul 28, 2015

Sorry for the horrible git fail there . . .

There is fix in the open pull request and a couple of tests. Would love another few eyes more familiar with the project to have a look over.

@beckettsean beckettsean modified the milestones: Next Point Release, 0.9.3 Aug 6, 2015
dawbs added a commit to dawbs/influxdb that referenced this issue Oct 8, 2015
…nerated in influxql/ast.go add the / char as a start and end delimiter, but does not escape any / characters that may exist with the regex
dgnorton added a commit that referenced this issue Oct 8, 2015
Bugfix for #3429 String representations of RegexLiterals generated in…
@jsternberg
Copy link
Contributor

It looks like a PR was merged for this bug for 0.9.5. I'm going to close out this issue. If this is still an issue, please reopen this ticket.

@jsternberg jsternberg removed this from the Future Point Release milestone Feb 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants