Skip to content

Found problem with backslashes parsing #307

@seregvan

Description

@seregvan

You closed my previous issue as a question so I'm opening a new one.
I think I found the problem in your parsing. I can't see the reason to do this in string literal parsing except the case when I try to find " in the result.

if (next == '"')
{
     NextChar();
}

Because if I use query "contains(\"\\\")" it fails with unterminated literal, but if I change query to "contains(\"\\a\")" it works finding "\a" string. And also if I use "contains(\"\\\\\")" it works with string "\\" (string with two real slashes).

So I think the correct solution will be to remove this if statement and just replace \" to " in the result token if it was a string literal. In this case if user will want to put " in query string it should be escaped inside this string. At least it will not break any existing code.
The better approach will be (in my opinion) to escape all the characters in the string by user and to unescape by parser. That means \\\\ will evaluate to \ and not to \\.
I understand your workaround by using @0 but it's not the case when search string comes outside my app.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions