Skip to content

Commit b4c4417

Browse files
MAGETWO-34293: Html minification works incorrectly in Layered Navigation
1 parent 808afad commit b4c4417

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<?php if ($block->getDisplayLabel()): ?>
1616
<span class="price-label"><?php echo $block->getDisplayLabel(); ?></span>
1717
<?php endif; ?>
18-
<span<?php if ($block->getPriceId()): ?> id="<?php echo $block->getPriceId() ?>"<?php endif;?>
18+
<span <?php if ($block->getPriceId()): ?> id="<?php echo $block->getPriceId() ?>"<?php endif;?>
1919
<?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
2020
data-price-amount="<?php echo $block->getAmount()->getValue(); ?>"
2121
data-price-type="<?php echo $block->getPriceType(); ?>"

lib/internal/Magento/Framework/Filesystem/Driver/File.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,4 +741,27 @@ public function getRealPath($path)
741741
{
742742
return realpath($path);
743743
}
744+
745+
/**
746+
* Return correct path for link
747+
*
748+
* @param string $path
749+
* @return mixed
750+
*/
751+
public function getRealPathSafety($path)
752+
{
753+
$pathParts = explode(DIRECTORY_SEPARATOR, $path);
754+
$realPath = [];
755+
foreach ($pathParts as $pathPart) {
756+
if ($pathPart == '.') {
757+
continue;
758+
}
759+
if ($pathPart == '..') {
760+
array_pop($realPath);
761+
continue;
762+
}
763+
$realPath[] = $pathPart;
764+
}
765+
return implode(DIRECTORY_SEPARATOR, $realPath);
766+
}
744767
}

lib/internal/Magento/Framework/Filesystem/DriverInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,14 @@ public function getAbsolutePath($basePath, $path, $scheme = null);
349349
*/
350350
public function getRealPath($path);
351351

352+
/**
353+
* Return correct path for link
354+
*
355+
* @param string $path
356+
* @return mixed
357+
*/
358+
public function getRealPathSafety($path);
359+
352360
/**
353361
* @param string $basePath
354362
* @param null $path

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function __construct(
8383
*/
8484
public function getMinified($file)
8585
{
86-
$file = $this->htmlDirectory->getDriver()->getRealPath($file);
86+
$file = $this->htmlDirectory->getDriver()->getRealPathSafety($file);
8787
if (!$this->htmlDirectory->isExist($this->rootDirectory->getRelativePath($file))) {
8888
$this->minify($file);
8989
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function testGetMinified()
166166
$htmlDriver = $this->getMock('Magento\Framework\Filesystem\DriverInterface', [], [], '', false);
167167
$htmlDriver
168168
->expects($this->once())
169-
->method('getRealPath')
169+
->method('getRealPathSafety')
170170
->willReturn($file);
171171

172172
$this->appDirectory

0 commit comments

Comments
 (0)