Skip to content
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

Prevent special characters finding their way into layout handle due to SKU being used #874

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/code/Magento/Catalog/Helper/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,26 @@ public function initProductLayout(ResultPage $resultPage, $product, $params = nu
$pageConfig->setPageLayout($settings->getPageLayout());
}

$urlSafeSku = rawurlencode($product->getSku());

// Load default page handles and page configurations
if ($params && $params->getBeforeHandles()) {
foreach ($params->getBeforeHandles() as $handle) {
$resultPage->addPageLayoutHandles(
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()],
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()],
$handle
);
}
}

$resultPage->addPageLayoutHandles(
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()]
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]
);

if ($params && $params->getAfterHandles()) {
foreach ($params->getAfterHandles() as $handle) {
$resultPage->addPageLayoutHandles(
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()],
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()],
$handle
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function _wrapEsi(
'page_cache/block/esi',
[
'blocks' => json_encode([$block->getNameInLayout()]),
'handles' => urlencode(json_encode($layout->getUpdate()->getHandles()))
'handles' => json_encode($layout->getUpdate()->getHandles())
]
);
return sprintf('<esi:include src="%s" />', $url);
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Review/Controller/Product/ListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ protected function _initProductLayout($product)
$pageConfig->setPageLayout($product->getPageLayout());
}
$update = $this->_view->getLayout()->getUpdate();

$urlSafeSku = rawurlencode($product->getSku());
$this->_view->addPageLayoutHandles(
['id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()]
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]
);

$this->_view->loadLayoutUpdates();
Expand Down