Skip to content

fix certain broken regular expressions by quoting

Warren Gifford requested to merge auto-quote-query into master

Created by: ijsnow

This PR addresses https://github.com/sourcegraph/sourcegraph/issues/2125. The query parser now places quotation marks around search queries (treats as a string literal) if they are a regular expression and are invalid for one of the following reasons:

  • There is an unclosed (
  • There is an unclosed [

Closes https://github.com/sourcegraph/sourcegraph/issues/2125.

The issue description currently says that we should also treat queries with unclosed { as well. However, I have determined that we do not need to do this. foo{ is a valid regular expression and behaves as expected. See this commit/test for proof.

Before merging, we should revert https://github.com/sourcegraph/sourcegraph/pull/2999/commits/65b600ca741d94e8170b65e12a69f3bda8405ff7.

Test plan: A test was added to the code.

Merge request reports

Loading