Skip to content

Commit d402bbd

Browse files
Fix XSS vulnerabilities in BML template and SeeALA MFTF test (#153)
1 parent 6e735fc commit d402bbd

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

Test/Mftf/Test/SeeALA.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
3030
</after>
3131

32-
<actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToStoreFront"/>
32+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="goToProductPage">
33+
<argument name="productUrl" value="$createSimpleProduct.custom_attributes[url_key]$"/>
34+
</actionGroup>
3335
<waitForPageLoad stepKey="waitForProductPage"/>
3436
<seeElement selector=".affirm-as-low-as" stepKey="seeBox"/>
3537
</test>

view/frontend/templates/promotion/aslowasCart.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ $learnMore = $block->getLearnMoreValue();
4343
. (!empty($mfpValue) ? 'data-promo-id="' . $block->escapeHtmlAttr($mfpValue) . '" ' : '')
4444
. $block->escapeHtmlAttr($block->getDataAffirmColor())
4545
. ' data-learnmore-show="' . $block->escapeHtmlAttr($learnMore) . '"></div>'; ?>
46-
</span>
46+
</span>

view/frontend/templates/promotion/bml.phtml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,24 @@
3535
?>
3636
<?php
3737
$mfpValue = $block->getMFPValue();
38-
$size = str_replace("--",'',$block->getSize());
39-
list($width, $height) = explode('x',$size);
38+
$size = str_replace("--", '', $block->getSize());
39+
list($width, $height) = explode('x', $size);
4040
$affirmAssetsUrl = $block->getAffirmAssetsUrl();
4141
$options = $block->getOptions();
4242
$pageType = $block->getPageType();
4343
?>
4444
<?= /* @noEscape */ $block->getStartContainerTag() ?>
45-
<?php
46-
/** @noEscape - Server-generated JSON for data-mage-init */ $optionsSafe = $options;
47-
$escapedMfpValue = $block->escapeHtmlAttr($mfpValue);
48-
$escapedPageType = $block->escapeHtmlAttr($pageType);
49-
$escapedWidth = $block->escapeHtmlAttr($width);
50-
$escapedHeight = $block->escapeHtmlAttr($height);
51-
$escapedImageUrl = $block->escapeUrl($affirmAssetsUrl . $size . '.png');
52-
// phpcs:ignore Magento2.Security.XssTemplate.FoundUnescaped -- All variables are pre-escaped above
53-
echo '<div class="affirm-banner-container">
54-
<a class="affirm-site-modal" data-mage-init=\'{"Astound_Affirm/js/affirmWidget": ' . /* @noEscape */ $optionsSafe . '}\''
55-
. (!empty($mfpValue) ? ' data-promo-id="' . /* @noEscape */ $escapedMfpValue . '"' : '')
56-
. (!empty($pageType) ? ' data-page-type="' . /* @noEscape */ $escapedPageType . '"' : '') . '>
57-
<img style="max-width:' . /* @noEscape */ $escapedWidth . 'px; max-height:' . /* @noEscape */ $escapedHeight . 'px; " src="' . /* @noEscape */ $escapedImageUrl . '">
58-
</a>
59-
</div>';
60-
?>
45+
<div class="affirm-banner-container">
46+
<a class="affirm-site-modal"
47+
data-mage-init='{"Astound_Affirm/js/affirmWidget": <?= /* @noEscape */ $options ?>}'
48+
<?php if (!empty($mfpValue)): ?>
49+
data-promo-id="<?= $escaper->escapeHtmlAttr($mfpValue) ?>"
50+
<?php endif; ?>
51+
<?php if (!empty($pageType)): ?>
52+
data-page-type="<?= $escaper->escapeHtmlAttr($pageType) ?>"
53+
<?php endif; ?>>
54+
<img style="max-width:<?= $escaper->escapeHtmlAttr($width) ?>px; max-height:<?= $escaper->escapeHtmlAttr($height) ?>px;"
55+
src="<?= $escaper->escapeUrl($affirmAssetsUrl . $size . '.png') ?>">
56+
</a>
57+
</div>
6158
<?= /* @noEscape */ $block->getEndContainerTag() ?>

0 commit comments

Comments
 (0)