Skip to content

Commit 8d58014

Browse files
committed
AC-7422: Incompatible issues fix for PHP8.2
--revert escaper changes
1 parent de30ecd commit 8d58014

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

app/code/Magento/Sales/Helper/Admin.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ public function escapeHtmlWithLinks($data, $allowedTags = null)
165165
$domDocument = $this->domDocumentFactory->create();
166166

167167
$internalErrors = libxml_use_internal_errors(true);
168-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
169-
$data = html_entity_decode(htmlentities($data, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'ISO-8859-1');
170168

169+
$data = mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8');
171170
$domDocument->loadHTML(
172171
'<html><body id="' . $wrapperElementId . '">' . $data . '</body></html>'
173172
);
@@ -193,7 +192,7 @@ public function escapeHtmlWithLinks($data, $allowedTags = null)
193192
}
194193
}
195194

196-
$result = htmlspecialchars_decode($domDocument->saveHTML(), ENT_QUOTES);
195+
$result = mb_convert_encoding($domDocument->saveHTML(), 'UTF-8', 'HTML-ENTITIES');
197196
preg_match('/<body id="' . $wrapperElementId . '">(.+)<\/body><\/html>$/si', $result, $matches);
198197
$data = !empty($matches) ? $matches[1] : '';
199198
}

lib/internal/Magento/Framework/Escaper.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Escaper
1717
{
1818
/**
1919
* HTML special characters flag
20-
* @var $htmlSpecialCharsFlag
20+
* @var int
2121
*/
2222
private $htmlSpecialCharsFlag = ENT_QUOTES | ENT_SUBSTITUTE;
2323

@@ -97,7 +97,7 @@ function ($errorNumber, $errorString) {
9797
}
9898
);
9999
$data = $this->prepareUnescapedCharacters($data);
100-
$string = @iconv("UTF-8", "ISO-8859-1//IGNORE", $data);
100+
$string = mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8');
101101
try {
102102
$domDocument->loadHTML(
103103
'<html><body id="' . $wrapperElementId . '">' . $string . '</body></html>'
@@ -114,7 +114,7 @@ function ($errorNumber, $errorString) {
114114
$this->escapeText($domDocument);
115115
$this->escapeAttributeValues($domDocument);
116116

117-
$result = html_entity_decode($domDocument->saveHTML(), ENT_QUOTES, 'UTF-8');
117+
$result = mb_convert_encoding($domDocument->saveHTML(), 'UTF-8', 'HTML-ENTITIES');
118118
preg_match('/<body id="' . $wrapperElementId . '">(.+)<\/body><\/html>$/si', $result, $matches);
119119
return !empty($matches) ? $matches[1] : '';
120120
} else {
@@ -347,7 +347,6 @@ public function escapeCss($string)
347347
* @param string $quote
348348
* @return string|array
349349
* @deprecated 101.0.0
350-
* @see 6729b6e01368248abc33300208eb292c95050203
351350
*/
352351
public function escapeJsQuote($data, $quote = '\'')
353352
{
@@ -368,7 +367,6 @@ public function escapeJsQuote($data, $quote = '\'')
368367
* @param string $data
369368
* @return string
370369
* @deprecated 101.0.0
371-
* @see 6729b6e01368248abc33300208eb292c95050203
372370
*/
373371
public function escapeXssInUrl($data)
374372
{
@@ -417,7 +415,6 @@ private function escapeScriptIdentifiers(string $data): string
417415
* @param bool $addSlashes
418416
* @return string
419417
* @deprecated 101.0.0
420-
* @see 6729b6e01368248abc33300208eb292c95050203
421418
*/
422419
public function escapeQuote($data, $addSlashes = false)
423420
{
@@ -432,7 +429,6 @@ public function escapeQuote($data, $addSlashes = false)
432429
*
433430
* @return \Magento\Framework\ZendEscaper
434431
* @deprecated 101.0.0
435-
* @see 6729b6e01368248abc33300208eb292c95050203
436432
*/
437433
private function getEscaper()
438434
{
@@ -448,7 +444,6 @@ private function getEscaper()
448444
*
449445
* @return \Psr\Log\LoggerInterface
450446
* @deprecated 101.0.0
451-
* @see 6729b6e01368248abc33300208eb292c95050203
452447
*/
453448
private function getLogger()
454449
{

0 commit comments

Comments
 (0)