Skip to content

Commit f7b0fe3

Browse files
authored
MAGETWO-80081: Escape html before replace new line with break magento#11058
2 parents 8f9fdf8 + 5e8e8b4 commit f7b0fe3

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/AddressTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testPrepareDataSource()
4747
{
4848
$itemName = 'itemName';
4949
$oldItemValue = "itemValue\n";
50-
$newItemValue = 'itemValue<br/>';
50+
$newItemValue = "itemValue<br />\n";
5151
$dataSource = [
5252
'data' => [
5353
'items' => [
@@ -57,7 +57,7 @@ public function testPrepareDataSource()
5757
];
5858

5959
$this->model->setData('name', $itemName);
60-
$this->escaper->expects($this->once())->method('escapeHtml')->with($newItemValue)->willReturnArgument(0);
60+
$this->escaper->expects($this->any())->method('escapeHtml')->with($oldItemValue)->willReturnArgument(0);
6161
$dataSource = $this->model->prepareDataSource($dataSource);
6262
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
6363
}

app/code/Magento/Sales/Ui/Component/Listing/Column/Address.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ public function prepareDataSource(array $dataSource)
4949
{
5050
if (isset($dataSource['data']['items'])) {
5151
foreach ($dataSource['data']['items'] as & $item) {
52-
$item[$this->getData('name')] = $this->escaper->escapeHtml(
53-
str_replace("\n", '<br/>', $item[$this->getData('name')])
54-
);
52+
$item[$this->getData('name')] = nl2br($this->escaper->escapeHtml($item[$this->getData('name')]));
5553
}
5654
}
5755

0 commit comments

Comments
 (0)