Skip to content

Commit

Permalink
bug #54079 [AssetMapper] Fix JavaScriptImportPathCompiler regressio…
Browse files Browse the repository at this point in the history
…n in regex (PhilETaylor)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[AssetMapper] Fix `JavaScriptImportPathCompiler` regression in regex

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues        | Fix #54078
| License       | MIT

Fixes regression in regex, fix provided by `@nicolas`-grekas in #54078

Commits
-------

ae16b2d [AssetMapper] Fix `JavaScriptImportPathCompiler` regression in regex
  • Loading branch information
nicolas-grekas committed Feb 29, 2024
2 parents 182e93e + ae16b2d commit 91278da
Showing 1 changed file with 5 additions and 6 deletions.
Expand Up @@ -28,16 +28,15 @@
final class JavaScriptImportPathCompiler implements AssetCompilerInterface
{
/**
* @see https://regex101.com/r/1iBAIb/1
* @see https://regex101.com/r/1iBAIb/2
*/
private const IMPORT_PATTERN = '/
^
(?:\/\/.*) # Lines that start with comments
^(?:\/\/.*) # Lines that start with comments
|
(?:
\'(?:[^\'\\\\\n]|\\\\.)*\' # Strings enclosed in single quotes
\'(?:[^\'\\\\\n]|\\\\.)*+\' # Strings enclosed in single quotes
|
"(?:[^"\\\\\n]|\\\\.)*" # Strings enclosed in double quotes
"(?:[^"\\\\\n]|\\\\.)*+" # Strings enclosed in double quotes
)
|
(?: # Import statements (script captured)
Expand All @@ -49,7 +48,7 @@ final class JavaScriptImportPathCompiler implements AssetCompilerInterface
|
\bimport\(
)
\s*[\'"`](\.\/[^\'"`\n]+|(\.\.\/)*[^\'"`\n]+)[\'"`]\s*[;\)]
\s*[\'"`](\.\/[^\'"`\n]++|(\.\.\/)*+[^\'"`\n]++)[\'"`]\s*[;\)]
?
/mx';

Expand Down

0 comments on commit 91278da

Please sign in to comment.