Skip to content

Commit dbc5070

Browse files
committed
MC-16608: Use escaper methods
- clean up code
1 parent fe332a8 commit dbc5070

File tree

26 files changed

+155
-158
lines changed

26 files changed

+155
-158
lines changed

app/code/Magento/AdminNotification/view/adminhtml/templates/notification/window.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"autoOpen": true,
1616
"buttons": false,
1717
"modalClass": "modal-system-messages",
18-
"title": "<?= $block->escapeHtml($block->getHeaderText()) ?>"
18+
"title": "<?= $block->escapeHtmlAttr($block->getHeaderText()) ?>"
1919
}
2020
}'>
2121
<li class="message message-warning warning">

app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
?>
99

1010
<div style="display:none" id="system_messages_list" data-role="system_messages_list"
11-
title="<?= $block->escapeHtml($block->getPopupTitle()) ?>">
11+
title="<?= $block->escapeHtmlAttr($block->getPopupTitle()) ?>">
1212
<ul class="message-system-list messages">
1313
<?php foreach ($block->getUnreadMessages() as $message) : ?>
14-
<li class="message message-warning <?= $block->escapeHtml($block->getItemClass($message)) ?>">
14+
<li class="message message-warning <?= $block->escapeHtmlAttr($block->getItemClass($message)) ?>">
1515
<?= $block->escapeHtml($message->getText()) ?>
1616
</li>
1717
<?php endforeach;?>

app/code/Magento/AdminNotification/view/adminhtml/templates/toolbar_entry.phtml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
<div
1313
data-mage-init='{"toolbarEntry": {}}'
1414
class="notifications-wrapper admin__action-dropdown-wrap"
15-
data-notification-count="<?= $block->escapeHtml($notificationCount) ?>">
15+
data-notification-count="<?= (int)$notificationCount ?>">
1616
<?php if ($notificationCount > 0) : ?>
1717
<a
1818
href="<?= $block->escapeUrl($block->getUrl('adminhtml/notification/index')) ?>"
1919
class="notifications-action admin__action-dropdown"
2020
data-mage-init='{"dropdown":{}}'
21-
title="<?= $block->escapeHtml(__('Notifications')) ?>"
21+
title="<?= $block->escapeHtmlAttr(__('Notifications')) ?>"
2222
data-toggle="dropdown">
2323
<span class="notifications-counter">
24-
<?= ($notificationCount > $notificationCounterMax) ? $block->escapeHtml($notificationCounterMax) . '+' : $block->escapeHtml($notificationCount) ?>
24+
<?= /* @noEscape */ ($notificationCount > $notificationCounterMax) ? (int)$notificationCounterMax . '+' : (int)$notificationCount ?>
2525
</span>
2626
</a>
2727
<ul
@@ -30,7 +30,7 @@
3030
<?php foreach ($block->getLatestUnreadNotifications() as $notification) : ?>
3131
<?php /** @var $notification \Magento\AdminNotification\Model\Inbox */ ?>
3232
<li class="notifications-entry<?php if ($notification->getSeverity() == 1) : ?> notifications-critical<?php endif; ?>"
33-
data-notification-id="<?= $block->escapeHtml($notification->getId()) ?>"
33+
data-notification-id="<?= $block->escapeHtmlAttr($notification->getId()) ?>"
3434
data-notification-severity="<?php if ($notification->getSeverity() == 1) : ?>1<?php endif; ?>">
3535
<?php
3636
$notificationDescription = $notification->getDescription();
@@ -59,23 +59,23 @@
5959
<button
6060
type="button"
6161
class="notifications-close"
62-
title="<?= $block->escapeHtml(__('Close')) ?>"
62+
title="<?= $block->escapeHtmlAttr(__('Close')) ?>"
6363
></button>
6464
</li>
6565
<?php endforeach; ?>
6666
<li class="notifications-entry notifications-entry-last">
6767
<a
6868
href="<?= $block->escapeUrl($block->getUrl('adminhtml/notification/index')) ?>"
6969
class="action-tertiary action-more">
70-
<?= $block->escapeHtml(__('See All (')) ?><span class="notifications-counter"><?= $block->escapeHtml($notificationCount) ?></span><?= $block->escapeHtml(__(' unread)')) ?>
70+
<?= $block->escapeHtml(__('See All (')) ?><span class="notifications-counter"><?= (int)$notificationCount ?></span><?= $block->escapeHtml(__(' unread)')) ?>
7171
</a>
7272
</li>
7373
</ul>
7474
<?php else : ?>
7575
<a
7676
class="notifications-action admin__action-dropdown"
7777
href="<?= $block->escapeUrl($block->getUrl('adminhtml/notification/index')) ?>"
78-
title="<?= $block->escapeHtml(__('Notifications')) ?>">
78+
title="<?= $block->escapeHtmlAttr(__('Notifications')) ?>">
7979
</a>
8080
<?php endif; ?>
8181
</div>

app/code/Magento/Backup/view/adminhtml/templates/backup/dialogs.phtml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
?>
77
<!-- TODO: refactor form styles and js -->
88
<script type="text/x-magento-template" id="rollback-warning-template">
9-
<p><?= $block->escapeHtml(__('You will lose any data created since the backup was made, including admin users, '
10-
. 'customers and orders.')) ?></p>
9+
<p><?= $block->escapeHtml(__('You will lose any data created since the backup was made, including admin users, customers and orders.')) ?></p>
1110
<p><?= $block->escapeHtml(__('Are you sure you want to continue?')) ?></p>
1211
</script>
1312
<script type="text/x-magento-template" id="backup-options-template">

app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,30 @@ $_htmlId = $block->getHtmlId() ? $block->getHtmlId() : '_' . uniqid();
1010
$_colspan = $block->isAddAfter() ? 2 : 1;
1111
?>
1212

13-
<div class="design_theme_ua_regexp" id="grid<?= $block->escapeHtml($_htmlId) ?>">
13+
<div class="design_theme_ua_regexp" id="grid<?= $block->escapeHtmlAttr($_htmlId) ?>">
1414
<div class="admin__control-table-wrapper">
15-
<table class="admin__control-table" id="<?= $block->escapeHtml($block->getElement()->getId()) ?>">
15+
<table class="admin__control-table" id="<?= $block->escapeHtmlAttr($block->getElement()->getId()) ?>">
1616
<thead>
1717
<tr>
1818
<?php foreach ($block->getColumns() as $columnName => $column) : ?>
1919
<th><?= $block->escapeHtml($column['label']) ?></th>
2020
<?php endforeach; ?>
21-
<th class="col-actions" colspan="<?= $block->escapeHtml($_colspan) ?>"><?= $block->escapeHtml(__('Action')) ?></th>
21+
<th class="col-actions" colspan="<?= (int)$_colspan ?>"><?= $block->escapeHtml(__('Action')) ?></th>
2222
</tr>
2323
</thead>
2424
<tfoot>
2525
<tr>
2626
<td colspan="<?= count($block->getColumns())+$_colspan ?>" class="col-actions-add">
27-
<button id="addToEndBtn<?= $block->escapeHtml($_htmlId) ?>" class="action-add"
28-
title="<?= $block->escapeHtml(__('Add')) ?>" type="button">
27+
<button id="addToEndBtn<?= $block->escapeHtmlAttr($_htmlId) ?>" class="action-add" title="<?= $block->escapeHtmlAttr(__('Add')) ?>" type="button">
2928
<span><?= $block->escapeHtml($block->getAddButtonLabel()) ?></span>
3029
</button>
3130
</td>
3231
</tr>
3332
</tfoot>
34-
<tbody id="addRow<?= $block->escapeHtml($_htmlId) ?>"></tbody>
33+
<tbody id="addRow<?= $block->escapeHtmlAttr($_htmlId) ?>"></tbody>
3534
</table>
3635
</div>
37-
<input type="hidden" name="<?= $block->escapeHtml($block->getElement()->getName()) ?>[__empty]" value="" />
36+
<input type="hidden" name="<?= $block->escapeHtmlAttr($block->getElement()->getName()) ?>[__empty]" value="" />
3837

3938
<script>
4039
require([
@@ -55,14 +54,14 @@ $_colspan = $block->isAddAfter() ? 2 : 1;
5554

5655
<?php if ($block->isAddAfter()) : ?>
5756
+ '<td><button class="action-add" type="button" id="addAfterBtn<%- _id %>"><span>'
58-
+ '<?= $block->escapeHtml(__('Add after')) ?>'
57+
+ '<?= $block->escapeJs($block->escapeHtml(__('Add after'))) ?>'
5958
+ '<\/span><\/button><\/td>'
6059
<?php endif; ?>
6160

6261
+ '<td class="col-actions"><button '
6362
+ 'onclick="arrayRow<?= $block->escapeJs($_htmlId) ?>.del(\'<%- _id %>\')" '
6463
+ 'class="action-delete" type="button">'
65-
+ '<span><?= $block->escapeHtml(__('Delete')) ?><\/span><\/button><\/td>'
64+
+ '<span><?= $block->escapeJs($block->escapeHtml(__('Delete'))) ?><\/span><\/button><\/td>'
6665
+ '<\/tr>'
6766
),
6867

@@ -123,7 +122,7 @@ $_colspan = $block->isAddAfter() ? 2 : 1;
123122
// add existing rows
124123
<?php
125124
foreach ($block->getArrayRows() as $_rowId => $_row) {
126-
echo /** noEscape */ "arrayRow{$block->escapeJs($_htmlId)}.add(" . /** noEscape */$_row->toJson() . ");\n";
125+
echo /* @noEscape */ "arrayRow{$block->escapeJs($_htmlId)}.add(" . /* @noEscape */ $_row->toJson() . ");\n";
127126
}
128127
?>
129128

app/code/Magento/Config/view/adminhtml/templates/system/config/js.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ originModel.prototype = {
6868
{
6969
this.reload = false;
7070
this.loader = new varienLoader(true);
71-
this.regionsUrl = "<?= $block->escapeUrl($block->getUrl('directory/json/countryRegion')) ?>";
71+
this.regionsUrl = "<?= $block->escapeJs($block->escapeUrl($block->getUrl('directory/json/countryRegion'))) ?>";
7272

7373
this.bindCountryRegionRelation();
7474
},

app/code/Magento/Config/view/adminhtml/templates/system/config/switcher.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
<?php if ($_option['is_close']) : ?>
1616
</optgroup>
1717
<?php else : ?>
18-
<optgroup label="<?= $block->escapeHtml($_option['label']) ?>"
19-
style="<?= $block->escapeHtml($_option['style']) ?>">
18+
<optgroup label="<?= $block->escapeHtmlAttr($_option['label']) ?>"
19+
style="<?= $block->escapeHtmlAttr($_option['style']) ?>">
2020
<?php endif; ?>
2121
<?php continue ?>
2222
<?php endif; ?>
23-
<option value="<?= $block->escapeHtml($_value) ?>"
23+
<option value="<?= $block->escapeHtmlAttr($_value) ?>"
2424
url="<?= $block->escapeUrl($_option['url']) ?>"
2525
<?= $_option['selected'] ? 'selected="selected"' : '' ?>
26-
style="<?= $block->escapeHtml($_option['style']) ?>">
26+
style="<?= $block->escapeHtmlAttr($_option['style']) ?>">
2727
<?= $block->escapeHtml($_option['label']) ?>
2828
</option>
2929
<?php endforeach ?>

app/code/Magento/Config/view/adminhtml/templates/system/config/tabs.phtml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
?>
99

1010
<?php if ($block->getTabs()) : ?>
11-
<div id="<?= $block->escapeHtml($block->getId()) ?>" class="config-nav">
11+
<div id="<?= $block->escapeHtmlAttr($block->getId()) ?>" class="config-nav">
1212
<?php
1313
/** @var $_tab \Magento\Config\Model\Config\Structure\Element\Tab */
1414
foreach ($block->getTabs() as $_tab) :
@@ -21,9 +21,9 @@
2121

2222
<div class="config-nav-block admin__page-nav _collapsed
2323
<?php if ($_tab->getClass()) : ?>
24-
<?= $block->escapeHtml($_tab->getClass()) ?>
24+
<?= $block->escapeHtmlAttr($_tab->getClass()) ?>
2525
<?php endif ?>"
26-
data-mage-init='{"collapsible":{"active": "<?= $block->escapeHtml($activeCollapsible) ?>",
26+
data-mage-init='{"collapsible":{"active": "<?= $block->escapeHtmlAttr($activeCollapsible) ?>",
2727
"openedState": "_show",
2828
"closedState": "_hide",
2929
"collapsible": true,

app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,28 @@
1111
?>
1212

1313
<form id="currency-symbols-form" action="<?= $block->escapeUrl($block->getFormActionUrl()) ?>" method="post">
14-
<input name="form_key" type="hidden" value="<?= $block->escapeHtml($block->getFormKey()) ?>" />
14+
<input name="form_key" type="hidden" value="<?= $block->escapeHtmlAttr($block->getFormKey()) ?>" />
1515
<fieldset class="admin__fieldset">
1616
<?php foreach ($block->getCurrencySymbolsData() as $code => $data) : ?>
1717
<div class="admin__field _required">
18-
<label class="admin__field-label" for="custom_currency_symbol<?= $block->escapeHtml($code) ?>">
18+
<label class="admin__field-label" for="custom_currency_symbol<?= $block->escapeHtmlAttr($code) ?>">
1919
<span><?= $block->escapeHtml($code) ?> (<?= $block->escapeHtml($data['displayName']) ?>)</span>
2020
</label>
2121
<div class="admin__field-control">
22-
<input id="custom_currency_symbol<?= $block->escapeHtml($code) ?>"
22+
<input id="custom_currency_symbol<?= $block->escapeHtmlAttr($code) ?>"
2323
class="required-entry admin__control-text <?= $data['inherited'] ? 'disabled' : '' ?>"
2424
type="text"
2525
value="<?= $block->escapeHtmlAttr($data['displaySymbol']) ?>"
26-
name="custom_currency_symbol[<?= $block->escapeHtml($code) ?>]">
26+
name="custom_currency_symbol[<?= $block->escapeHtmlAttr($code) ?>]">
2727
<div class="admin__field admin__field-option">
28-
<input id="custom_currency_symbol_inherit<?= $block->escapeHtml($code) ?>"
28+
<input id="custom_currency_symbol_inherit<?= $block->escapeHtmlAttr($code) ?>"
2929
class="admin__control-checkbox" type="checkbox"
30-
onclick="toggleUseDefault(<?= '\'' . $block->escapeHtml($code) . '\',\'' .
31-
$block->escapeJs($data['parentSymbol']) . '\'' ?>)"
30+
onclick="toggleUseDefault(<?= '\'' . $block->escapeJs($code) . '\',\'' . $block->escapeJs($data['parentSymbol']) . '\'' ?>)"
3231
<?= $data['inherited'] ? ' checked="checked"' : '' ?>
3332
value="1"
34-
name="inherit_custom_currency_symbol[<?= $block->escapeHtml($code) ?>]">
33+
name="inherit_custom_currency_symbol[<?= $block->escapeHtmlAttr($code) ?>]">
3534
<label class="admin__field-label"
36-
for="custom_currency_symbol_inherit<?= $block->escapeHtml($code) ?>">
35+
for="custom_currency_symbol_inherit<?= $block->escapeHtmlAttr($code) ?>">
3736
<span>
3837
<?= $block->escapeHtml($block->getInheritText()) ?>
3938
</span>

app/code/Magento/CurrencySymbol/view/adminhtml/templates/system/currency/rate/matrix.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ $_rates = ($_newRates) ? $_newRates : $_oldRates;
3535
<td><span class="admin__control-support-text"><?= $block->escapeHtml($_currencyCode) ?></span></td>
3636
<td>
3737
<input type="text"
38-
name="rate[<?= $block->escapeHtml($_currencyCode) ?>][<?= $block->escapeHtml($_rate) ?>]"
39-
value="<?= ($_currencyCode == $_rate) ? '1.0000' : ($_value>0 ? $block->escapeHtml($_value) : (isset($_oldRates[$_currencyCode][$_rate]) ? $block->escapeHtml($_oldRates[$_currencyCode][$_rate]) : '')) ?>"
38+
name="rate[<?= $block->escapeHtmlAttr($_currencyCode) ?>][<?= $block->escapeHtmlAttr($_rate) ?>]"
39+
value="<?= ($_currencyCode == $_rate) ? '1.0000' : ($_value>0 ? $block->escapeHtmlAttr($_value) : (isset($_oldRates[$_currencyCode][$_rate]) ? $block->escapeHtmlAttr($_oldRates[$_currencyCode][$_rate]) : '')) ?>"
4040
class="admin__control-text"
4141
<?= ($_currencyCode == $_rate) ? ' disabled' : '' ?> />
4242
<?php if (isset($_newRates) && $_currencyCode != $_rate && isset($_oldRates[$_currencyCode][$_rate])) : ?>
@@ -46,8 +46,8 @@ $_rates = ($_newRates) ? $_newRates : $_oldRates;
4646
<?php else : ?>
4747
<td>
4848
<input type="text"
49-
name="rate[<?= $block->escapeHtml($_currencyCode) ?>][<?= $block->escapeHtml($_rate) ?>]"
50-
value="<?= ($_currencyCode == $_rate) ? '1.0000' : ($_value>0 ? $block->escapeHtml($_value) : (isset($_oldRates[$_currencyCode][$_rate]) ? $block->escapeHtml($_oldRates[$_currencyCode][$_rate]) : '')) ?>"
49+
name="rate[<?= $block->escapeHtmlAttr($_currencyCode) ?>][<?= $block->escapeHtmlAttr($_rate) ?>]"
50+
value="<?= ($_currencyCode == $_rate) ? '1.0000' : ($_value>0 ? $block->escapeHtmlAttr($_value) : (isset($_oldRates[$_currencyCode][$_rate]) ? $block->escapeHtmlAttr($_oldRates[$_currencyCode][$_rate]) : '')) ?>"
5151
class="admin__control-text"
5252
<?= ($_currencyCode == $_rate) ? ' disabled' : '' ?> />
5353
<?php if (isset($_newRates) && $_currencyCode != $_rate && isset($_oldRates[$_currencyCode][$_rate])) : ?>

0 commit comments

Comments
 (0)