Skip to content

Commit 4d65656

Browse files
committed
MC-35699: [Magento Cloud] HTML minification strips triple slashes from html string in phtml
1 parent be26941 commit 4d65656

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Framework\View\Template\Html;
89

@@ -140,7 +141,7 @@ function ($match) use (&$heredocs) {
140141
. '(?:<(?>textarea|pre|script)\b|\z))#',
141142
' ',
142143
preg_replace(
143-
'#(?<!:|\\\\|\'|")//(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#',
144+
'#(?<!:|\\\\|\'|"|/)//(?!/)(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#',
144145
'',
145146
preg_replace(
146147
'#(?<!:|\'|")//[^\n\r]*(\?\>)#',

lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Framework\View\Test\Unit\Template\Html;
79

810
use PHPUnit\Framework\TestCase;
@@ -139,6 +141,7 @@ public function testMinify()
139141
<img src="test.png" alt="some text" />
140142
<?php echo \$block->someMethod(); ?>
141143
<div style="width: 800px" class="<?php echo \$block->getClass() ?>" />
144+
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-component="main-image">
142145
<script>
143146
var i = 1;// comment
144147
var j = 1;// <?php echo 'hi' ?>
@@ -179,7 +182,7 @@ public function testMinify()
179182
TEXT;
180183

181184
$expectedContent = <<<TEXT
182-
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ ?> <?php ?> <html><head><title>Test title</title></head><link rel="stylesheet" href='https://www.example.com/2' type="text/css" /><link rel="stylesheet" type="text/css" media="all" href="https://www.example.com/1" type="text/css" /><body><a href="http://somelink.com/text.html">Text Link</a> <img src="test.png" alt="some text" /><?php echo \$block->someMethod(); ?> <div style="width: 800px" class="<?php echo \$block->getClass() ?>" /><script>
185+
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ ?> <?php ?> <html><head><title>Test title</title></head><link rel="stylesheet" href='https://www.example.com/2' type="text/css" /><link rel="stylesheet" type="text/css" media="all" href="https://www.example.com/1" type="text/css" /><body><a href="http://somelink.com/text.html">Text Link</a> <img src="test.png" alt="some text" /><?php echo \$block->someMethod(); ?> <div style="width: 800px" class="<?php echo \$block->getClass() ?>" /><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-component="main-image"><script>
183186
var i = 1;
184187
var j = 1;
185188

0 commit comments

Comments
 (0)