Repository navigation
Conversation
|
Hi @asxxb! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary
writeCodePointToUTF16()inlib/Regex/RegexParser.cppcheckedcp <= 0x10000instead ofisMemberOfBMP(cp)(cp <= 0xFFFF). SinceU+10000is a validID_Startcharacter, an escapedU+10000in a named capture group or\k<...>backreference (such as/(?<\u{10000}>a)/or/(?<\uD800\uDC00>a)/) took the BMP branch and got cast to(char16_t)0x10000, storing\0instead of the surrogate pair\uD800\uDC00.This caused:
/(?<\u{10000}>a)/.exec("a").groupsto expose key"\0"instead of"\u{10000}"/(?<𐀀>a)\k<\u{10000}>/to fail to compile withNonexistent named capture reference/(?<𐀀>a)(?<\u{10000}>b)/to miss the duplicate capture group name checkChanged the check to
isMemberOfBMP(cp)soU+10000encodes as a surrogate pair, matching literalU+10000group names.Test Plan
Regex.NamedGroupU10000Escapeinunittests/Support/RegexTest.cpp(verified it failed before the fix and passes after).test/hermes/regress-regexp-group-name-u10000.js.MinSizeRel build on macOS arm64:
Results:
HermesSupportTests --gtest_filter="Regex.*": 16 passed, 0 failedregress-regexp-group-name-u10000.js,regexp-duplicate-named-groups.js,regexp.js: all passed withFileCheck