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

Quoting nested quotes in DSL parser is broken #72

Closed
dgryski opened this issue Aug 22, 2020 · 4 comments
Closed

Quoting nested quotes in DSL parser is broken #72

dgryski opened this issue Aug 22, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@dgryski
Copy link
Contributor

dgryski commented Aug 22, 2020

I've been trying to port this semgrep rule to ruleguard: dgryski/semgrep-go#1

I've gotten hung up on trying to port over the rules due to the different types of quoting involved. The DSL seems to need extra \ to escape double-quotes, but the those \ are expected to show up in the actual source text.

For example, the match text

m.Match("fmt.Sprintf(`\"%s\" <%s>`, $NAME, $EMAIL)")

Only matches the text

        fmt.Println(fmt.Sprintf(`\"%s\" <%s>`, "name", "email@domain.example"))

and doesn't match the text without the slashes escaping the quotes

@quasilyte quasilyte added the bug Something isn't working label Aug 22, 2020
@quasilyte quasilyte self-assigned this Aug 22, 2020
quasilyte added a commit that referenced this issue Aug 22, 2020
Instead of just dropping the both quotes, do the
actual unquoting that may involve some string interpretation
in case of the "-literals.

strconv.Unquote() is the right way to do it.

Refs #72

Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
quasilyte added a commit that referenced this issue Aug 22, 2020
Instead of just dropping the both quotes, do the
actual unquoting that may involve some string interpretation
in case of the "-literals.

strconv.Unquote() is the right way to do it.

Refs #72

Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
@dgryski
Copy link
Contributor Author

dgryski commented Aug 22, 2020

Your patch fixes my issue.

@quasilyte
Copy link
Owner

Thank you for reporting this issue. 👍 It really helps.

@dgryski
Copy link
Contributor Author

dgryski commented Aug 29, 2020

Can this be closed or is there more work?

@quasilyte
Copy link
Owner

quasilyte commented Aug 29, 2020

I believe it can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants