-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[AssetMapper] Fix JavaScriptImportPathCompiler
regex for non-latin characters
#58659
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
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Hey! Thanks for your PR. You are targeting branch "6.4" but it seems your PR description refers to branch "6.4 and 7.*". Cheers! Carsonbot |
@@ -42,7 +42,7 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface | |||
(?: # Import statements (script captured) | |||
import\s* | |||
(?: | |||
(?:\*\s*as\s+\w+|\s+[\w\s{},*]+) | |||
(?:\*\s*as\s+\w+|\s+[\p{L}\w\s{},*]+) |
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.
I don't know which encoding PCRE uses when the u
modifier isn't set, but this doesn't work with e.g. character é
.
I think the correct patch is to add the u
modifier when the input is UTF-8 and contains non-ascii chars:
self::IMPORT_PATTERN.(preg_match('{[^\\x00-\\x7F]}u') ? 'u' : '')
then this change here should be reverted
JavaScriptImportPathCompiler
regex for non-latin characters
@@ -50,7 +50,7 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface | |||
) | |||
\s*[\'"`](\.\/[^\'"`\n]++|(\.\.\/)*+[^\'"`\n]++)[\'"`]\s*[;\)] | |||
? | |||
/mx'; | |||
/mxu'; |
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.
This will break parsing non UTF8 files. My previous suggestion was made to handle such cases.
We can merge as is and wait for someone to fill in a bug, maybe UTF-8 is the only encoding found in practice?
🤷
Thank you @GregRbs92. |
Update the regex in
JavaScriptImportPathCompiler
so that imported functions having non-latin characters still match the regex.Example
The code above was not working prio to this fix, because of the
ɵ