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

Invalid regex patterns not properly detected. #283

Open
Lord-Kamina opened this issue Oct 13, 2022 · 2 comments
Open

Invalid regex patterns not properly detected. #283

Lord-Kamina opened this issue Oct 13, 2022 · 2 comments

Comments

@Lord-Kamina
Copy link

I've noticed, due to how the lexer is written, it's not particularly difficult to make invalid patterns that won't be detected as being erroneous, specifically when ')' appears at weird locations.

Routes such as "/:foo([123]+))", or "/:foo)([123]+)" should give an error, but they don't.

@blakeembrey
Copy link
Member

It's not particularly difficult to add that to detect if you want to open a PR, but it'd have to be part of a new major release since it's a breaking change for anyone potentially using these patterns for whatever reason.

@Lord-Kamina
Copy link
Author

It's not particularly difficult to add that to detect if you want to open a PR, but it'd have to be part of a new major release since it's a breaking change for anyone potentially using these patterns for whatever reason.

I'm toying around with having a boolean character_class that is set to true when an unescaped [ is found and back to false when a ] is found. My idea would be to treat brackets as groups only when this switch is on; then a check for ) could give an error. Not entirely sure of what other repercussions this can have though, so I won't commit anything for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants