Skip to content

Chore: Cookie - Replace Block Escaping with Escaper #37076

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

Closed
wants to merge 1 commit into from
Closed
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
30 changes: 18 additions & 12 deletions app/code/Magento/Cookie/view/frontend/templates/html/notices.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,36 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

/** @var \Magento\Cookie\Block\Html\Notices $block */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
<?php
/** @var \Magento\Cookie\Helper\Cookie $cookieHelper */
use Magento\Cookie\Block\Html\Notices;
use Magento\Cookie\Helper\Cookie;
use Magento\Framework\Escaper;
use Magento\Framework\View\Helper\SecureHtmlRenderer;

/** @var Escaper $escaper */
/** @var Notices $block */
/** @var SecureHtmlRenderer $secureRenderer */
/** @var Cookie $cookieHelper */
$cookieHelper = $block->getData('cookieHelper');
if ($cookieHelper->isCookieRestrictionModeEnabled()): ?>
?>
<?php if ($cookieHelper->isCookieRestrictionModeEnabled()): ?>
<div role="alertdialog"
tabindex="-1"
class="message global cookie"
id="notice-cookie-block">
<div role="document" class="content" tabindex="0">
<p>
<strong><?= $block->escapeHtml(__('We use cookies to make your experience better.')) ?></strong>
<span><?= $block->escapeHtml(__(
<strong><?= $escaper->escapeHtml(__('We use cookies to make your experience better.')) ?></strong>
<span><?= $escaper->escapeHtml(__(
'To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies.'
)) ?>
</span>
<?= $block->escapeHtml(__('<a href="%1">Learn more</a>.', $block->getPrivacyPolicyLink()), ['a']) ?>
<?= $escaper->escapeHtml(__('<a href="%1">Learn more</a>.', $block->getPrivacyPolicyLink()), ['a']) ?>
</p>
<div class="actions">
<button id="btn-cookie-allow" class="action allow primary">
<span><?= $block->escapeHtml(__('Allow Cookies')) ?></span>
<span><?= $escaper->escapeHtml(__('Allow Cookies')) ?></span>
</button>
</div>
</div>
Expand All @@ -37,10 +43,10 @@ if ($cookieHelper->isCookieRestrictionModeEnabled()): ?>
"#notice-cookie-block": {
"cookieNotices": {
"cookieAllowButtonSelector": "#btn-cookie-allow",
"cookieName": "<?= /* @noEscape */ \Magento\Cookie\Helper\Cookie::IS_USER_ALLOWED_SAVE_COOKIE ?>",
"cookieName": "<?= /* @noEscape */ Cookie::IS_USER_ALLOWED_SAVE_COOKIE ?>",
"cookieValue": <?= /* @noEscape */ $cookieHelper->getAcceptedSaveCookiesWebsiteIds() ?>,
"cookieLifetime": <?= /* @noEscape */ $cookieHelper->getCookieRestrictionLifetime() ?>,
"noCookiesUrl": "<?= $block->escapeJs($block->getUrl('cookie/index/noCookies')) ?>"
"noCookiesUrl": "<?= $escaper->escapeJs($block->getUrl('cookie/index/noCookies')) ?>"
}
}
}
Expand Down