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

Add error code for unsupported PCRE cases (RE_EUNSUPPPCRE), reject one. #447

Merged
merged 4 commits into from
Jan 11, 2024

Conversation

silentbicycle
Copy link
Collaborator

@silentbicycle silentbicycle commented Oct 19, 2023

There's extra error codes in #440 for regexes that aren't UNSATISFIABLE per se, but depend on particular corner cases in PCRE that probably aren't worth supporting in an automata-based implementation.

Add a test case for one, tests/pcre/in48.re: ^a|$[^x]b*

This is a tricky one to handle properly; according to PCRE it should match either "a<anything...>" OR "\n", but nothing else. The newline match is because $ is a non-input-consuming check that evaluation is either at the end of input, or at a newline immediately before the end. In this case $[^x]b* matches exactly one newline; it's equivalent to "$\n". This probably isn't worth supporting, but we can detect cases where a potential newline match appears after a $ and reject them as an unsupported PCRE behavior.

There's extra error codes in #440 for regexes that aren't UNSATISFIABLE
per se, but depend on particular corner cases in PCRE that probably
aren't worth supporting in an automata-based implementation.

Add a test case for one, tests/pcre/in48.re: ^a|$[^x]b*

This is a tricky one to handle properly; according to PCRE it should
match either "a<anything...>" OR "\n", but nothing else. The newline
match is because $ is a non-input-consuming check that evaluation is
either at the end of input, or at a newline immediately before the end.
In this case `$[^x]b*` matches exactly one newline; it's equivalent to
"$\n". This probably isn't worth supporting, but we can detect cases
where a potential newline match appears after a $ and reject them as
an unsupported PCRE behavior.
@silentbicycle silentbicycle marked this pull request as ready for review October 19, 2023 18:03
silentbicycle added a commit that referenced this pull request Oct 19, 2023
…is' into sv/integrate-combinable-DFA-capture-resolution--fuzzing-branch

Integrate #447's changes for continuing local fuzzing. It hasn't been reviewed yet.
src/libre/ast.h Outdated
@@ -98,6 +98,7 @@ enum ast_flags {
AST_FLAG_ANCHORED_START = 1 << 6,
AST_FLAG_ANCHORED_END = 1 << 7,
AST_FLAG_END_NL = 1 << 8,
AST_FLAG_MATCHES_1NEWLINE= 1 << 9,
Copy link
Owner

Choose a reason for hiding this comment

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

lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There will be even more niche start/end anchor flags coming soon. Expressing PCRE's anchoring rules statically gets complicated.

src/libre/ast_analysis.c Outdated Show resolved Hide resolved
@silentbicycle
Copy link
Collaborator Author

I merged in a recent main and spent a bit more time trying to actually hit the possibly unreachable branch above.

@katef katef merged commit fdd18f4 into main Jan 11, 2024
322 checks passed
@katef katef deleted the sv/reject-unsupported-pcre-extensions-during-ast-analysis branch January 11, 2024 23:01
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