Skip to content

[bug] Escaped quotes in a quoted keyword search are searched with the backslashes #1687

Description

@breken-ai

Describe the bug

The syntax reference says "foo \"bar\"" matches files containing foo "bar". In keyword mode (the default) it matches nothing: the parser strips the outer quotes but keeps the backslashes, so zoekt gets the substring foo \"bar\". The same happens with \\ and with quoted content: values.

Expected: in keyword mode, \" and \\ inside a quoted term are unescaped before the substring query is built. Regex mode can keep them as-is.

To reproduce

  1. Index a repo with a file containing foo "bar".
  2. Search "foo \"bar\"" in keyword mode. No results.

Or in code: parseQuerySyntaxIntoIR on "foo \"bar\"" returns substring.pattern = foo \"bar\" instead of foo "bar". The cause is the QuotedTerm and ContentExpr cases of transformTreeToIR in packages/web/src/features/search/parser.ts.

Sourcebot deployment information

Sourcebot version (e.g. v3.0.1): main @ b493151 (found reading the source and confirmed with a unit test, not on a deployment)

Additional information

I have a small fix with tests ready and will open a PR that links this issue. (Found by an AI coding agent working for the breken-ai account.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions