-
Notifications
You must be signed in to change notification settings - Fork 632
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
Support regex named capture groups #696
Comments
Thanks for sharing this. As shared in the previous issue, named capture groups are an ES2018 feature that we have not implemented in Hermes yet. Note that for most cases, you should be able to get away with a babel transform for named capture groups, as described here. |
@neildhar thanks, after installing the @babel/plugin-transform-named-capturing-groups-regex and adding it in the plugin array in my babel.config.js file, it works now :) 🚀 |
### Description - Upgrade `@celo/utils` to fix vulnerability in `@umpirsky/country-list`: GHSA-hj79-42mx-m4gr - The upgraded `@celo/utils` caused a new parsing error with hermes as it [doesn't support named capture groups in RegEx](facebook/hermes#696). It was solved by adding `@babel/plugin-transform-named-capturing-groups-regex` to our babel transforms. - Upgrade `shell-quote` to fix vulnerability: GHSA-g4rg-993r-mgx7 ### Other changes N/A ### Tested The app + phone verification should work as expected ### How others should test Please test the phone verification and confirm that it works as expected (there should be no change as a result of this PR) ### Related issues Discussed on [Slack](https://valora-app.slack.com/archives/CL7BVQPHB/p1655807207073809). ### Backwards compatibility Yes Co-authored-by: Kathy Luo <kathyluo18@gmail.com> Co-authored-by: Jean Regisser <jean.regisser@gmail.com>
@neildhar thanks for the babel transform suggestion! |
Wanted to update this thread- named capture groups will be supported natively by Hermes soon! The work is already done, we are just making some minor changes and revisions now. It will most likely be landing in the next week or so! |
@fbmal7 any ETA? I found this is quite a problem for us - and unfortunately adding |
Friendly bump. @fbmal7 any news? Edit: I'd also encourage people upvoting the comments further down to upvote the first comment, as repo maintainers can see which issues have the most thumbs-ups. |
@slapbox Sorry I should have updated this thread again earlier! Native support for named capture groups has been in hermes since Oct 7th, with c2d622. RN 0.70 was first cut on Jul 15th. RN 0.71 was first cut on Nov 3rd. So, named capture groups won't be usable in RN 0.70, but should be there in 0.71. |
If you can't upgrade to 0.71 now, you also can try a workaround.
|
As per this issue, named capture groups won't be supported by Hermes until RN 0.71: facebook/hermes#696 With this commit, the latest version of '@babel/plugin-transform-named-capturing-groups-regex' has been installed to workaround this.
As per this issue, Hermes doesn't currently support named capturing groups: facebook/hermes#696 This commit addresses that by using the 'plugin-transform-named-capturing-groups-regex' plugin.
In my case I use create a Regex with the search text entered by the user.
Getting similar errors when users enters For the moment I'm adding extra
But I don't like this workaround. Is there a better way to fix this issue? (I'm using react-native 0.68.3) |
@malwatte that's a really quick way to break things, since it's very unsafe to put unsanitized user input into a regex. |
@ljharb Appreciate if you can suggest better way to do. I need to do a search using the user input text. Thanks. |
Problem
Follow up on #89 :
Currently, when using Hermes to build a React Native app, when it tries to include a dependency using regex named capture groups, the app build process crashes.
Example code from real dependency:
Build Error:
SyntaxError: Invalid RegExp pattern: Quantifier has nothing to repeat, js engine: hermes
'?<colorString>' being the invalid pattern.
Solution
I am unfamiliar with the required work to solve this, but I am assuming the Hermes Javascript engine core would need to be upgraded to add support for named capture groups. Update the engine parse/lexer to process named groups? Use an existing regex library?
The text was updated successfully, but these errors were encountered: