Skip to content

Commit 5fbf10b

Browse files
committed
Do not break JS RegExps that look like comments
For example, prevent "/\/path\/to\//" from being replaced with "/\/path\/to\"
1 parent 06f667b commit 5fbf10b

File tree

1 file changed

+2
-2
lines changed
  • lib/internal/Magento/Framework/View/Template/Html

1 file changed

+2
-2
lines changed

lib/internal/Magento/Framework/View/Template/Html/Minifier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ function ($match) use (&$heredocs) {
162162
. '(?:<(?>textarea|pre|script)\b|\z))#',
163163
' ',
164164
preg_replace(
165-
'#(?<!:|\\\\|\'|"|/)//(?!/)(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*'
165+
'#(?<!:|\\\\|\\\|\'|"|/)//(?!/)(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*'
166166
. '(?!(?:(?:[^<]++|<(?!/?(?:script)\b))*+)(?:<(?>script)\b|\z))#',
167167
'',
168168
preg_replace(
169-
'#(?<!:)//[^\n\r]*(\<\?(php|=))[^\n\r]*(\s\?\>)[^\n\r]*'
169+
'#(?<!:|\\\)//[^\n\r]*(\<\?(php|=))[^\n\r]*(\s\?\>)[^\n\r]*'
170170
. '(?!(?:(?:[^<]++|<(?!/?(?:script)\b))*+)(?:<(?>script)\b|\z))#',
171171
'',
172172
($content ?? '')

0 commit comments

Comments
 (0)