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

Unsafe joining of regexs #17

Closed
k-wall opened this issue Feb 26, 2024 · 2 comments
Closed

Unsafe joining of regexs #17

k-wall opened this issue Feb 26, 2024 · 2 comments

Comments

@k-wall
Copy link

k-wall commented Feb 26, 2024

The intent is the regular expressions are joined with a logic OR.

However the approach is weak. The results of the match could be wrong, or regular expression parsing errors might be misleading.

For instance input like hell[o,s]world would lead to a valid regex hell[o|s]worldbut with the pipe being interpreted literally rather than a logic or(which would match literal hell|world). The correct behaviour would be to be told that hell[o is not a valid regex.

Another example would be hello\\,world which would lead to an escaped pipe.

@k-wall
Copy link
Author

k-wall commented Feb 26, 2024

It is probably best to compile the expressions individually, and test the input against each pattern individually. Or, assemble a regex after you've validated that each part is a syntactically valid regex in some safe manner that respects RE precedence rules.. something like (pat1)|(pat2).... We'd need tests to ensure that anchors work properly.

@mimaison
Copy link
Contributor

Fixed in #32

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

No branches or pull requests

3 participants