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

Fixing Escaped Strings in the Sparql Parser #300

Merged
merged 8 commits into from Jan 4, 2020

Conversation

joka921
Copy link
Member

@joka921 joka921 commented Jan 3, 2020

Previously, Regex Filters that contained Escape Sequences were neither handled correct
by the Lexer nor by the Parser (see #296). This PR fixes these bugs.

It implements a function to unify the different ways to specify Strings in Sparql/Turtle (" with escapes versus """ without escapes) to a form, that performs unescaping of \t \n \\\"...

Currently, the handling of strings that contain escaped characters is also wrong in the turtle Parser.
However to fix this, we require some more changes since the serialization of the vocabulary has to be changed as soon as the vocabulary elements may contain \n characters. So I would recommend first merging this and then using it as a base for the other fix.

TODO: The method is not the most efficient, so we can as well make it safe.
TODO: test that illegal inputs always throw and never segfault.
const std::string SparqlLexer::WS = "(\\x20|\\x09|\\x0D|\\x0A)";
const std::string SparqlLexer::ECHAR = "\\\\[tbnrf\"']";
const std::string SparqlLexer::WS = R"((\x20|\x09|\x0D|\x0A))";
const std::string SparqlLexer::ECHAR = R"(\\[tbnrf\\"'])";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first of those lines is just a reformatting.
In the second line their were two backslashes missing.

Copy link
Member

@niklas88 niklas88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for this, I'm betting this caused quite a headache to figure out

@niklas88 niklas88 merged commit 6b82fac into ad-freiburg:master Jan 4, 2020
@joka921 joka921 deleted the f.FixEscapeLexer branch May 8, 2021 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants