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
Swift: Recognize regular expression parse mode flags #13715
base: main
Are you sure you want to change the base?
Conversation
|
The multiple modes commit looks good to me, and I think the other languages could use a port of that fix. I don't know of other languages that support limitations 3-5. |
| * MULTILINE | ||
| * UNICODE | ||
| */ | ||
| string getAMode() { result = this.getModeFromPrefix() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the advantage of splitting the implementation out into the separate getModeFromPrefix?
Recognize regular expression parse mode flags in Swift. For example in
(?i)foo, the(?i)specifies a case-insensitive match of the rest of the regular expressionfoo.This improves the accuracy of the REDOS and bad HTML filtering queries (and others to come).
Limitations:
foo(?i)bar, which is allowed in Swift(?i:foo)bar, which is allowed in Swift(?i-s), which is allowed in Swift@erik-krogh @joefarebrother the initial version of this was based on code from Java and is also very similar to Python. I found that we were failing to recognize multiple mode flags (e.g.
(?is)), which I fixed with 6e80021. Please could you review those changes with a view to both correctness for Swift, and whether or not it would be desirable for me to port that fix to Java and/or Python?I'm also curious whether we support any of what I described in limitations 3-5 above in other languages. I suspect we do not, which makes it a pretty low priority for Swift where we're currently playing catch-up - but if we do it would be a starting point to solving them.