Skip to content

Commit 5fbf54a

Browse files
committed
AC-9831: Block template render enhancement
1 parent f59f51e commit 5fbf54a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/internal/Magento/Framework/View/Element/Html/Link.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ private function renderSpecialAttributes(): string
184184
);
185185
}
186186
}
187-
188-
return $html;
187+
return $this->_escaper->escapeJsQuote($html);
189188
}
190189
}

lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,14 @@ public function testLinkHtml(): void
161161
$this->link->setDataUsingMethod('style', 'display: block;');
162162
$this->link->setDataUsingMethod('onclick', 'alert("clicked");');
163163

164+
/** @var Escaper $escaper */
165+
$escaper = $this->objectManager->getObject(Escaper::class);
166+
164167
$html = $this->link->toHtml();
165168
$this->assertEquals(
166-
'<li><a href="http://site.com/link.html" id="idrandom" ></a></li>'
169+
$escaper->escapeJsQuote('<li><a href="http://site.com/link.html" id="idrandom" ></a></li>'
167170
.'<style>#idrandom { display: block; }</style>'
168-
.'<script>document.querySelector(\'#idrandom\').onclick = function () { alert("clicked"); };</script>',
171+
.'<script>document.querySelector(\'#idrandom\').onclick = function () { alert("clicked"); };</script>'),
169172
$html
170173
);
171174
}

0 commit comments

Comments
 (0)