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

Handle all none unicode character class escapes natively #439

Merged
merged 1 commit into from
Oct 21, 2023

Conversation

tjenkinson
Copy link
Owner

@tjenkinson tjenkinson commented Oct 15, 2023

Before this change we would not resolve character class escapes (with the exception of \d) to their possible values.

This meant that a pattern like /\w+\W+/ would be considered vulnerable even though /[a-zA-Z0-9_]+[^a-zA-Z0-9_]+/ would not, because it didn't know that there was no overlap in possible values between \w and \W. Note there was some logic that would cancel out exact inversions if it was written like /\w+[^\w]+/.

All none unicode character class escapes are now resolved to their possible values.

Unicode escapes are not expanded, and I'm not sure how to safely support those given the contents of different unicode properties can change over time when new unicode versions are released. Also there's currently no api to ask the browser what version of unicode it's on or what the contents of a unicode property are.

This now means /^[\w+-]+(?:\.[\w+-]+)*@[\da-zA-Z]+(?:[.-][\da-zA-Z]+)*\.[a-zA-Z]{2,}$/u used in some places for validating email addresses is now marked as safe, where it previously wasn't.

@tjenkinson tjenkinson force-pushed the handle-more-character-classes branch 2 times, most recently from 4b82d85 to ece1ede Compare October 15, 2023 16:16
@tjenkinson tjenkinson merged commit 2a5cb51 into main Oct 21, 2023
6 checks passed
@tjenkinson tjenkinson deleted the handle-more-character-classes branch October 21, 2023 18:09
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

1 participant