Skip to content

Commit 847d20f

Browse files
author
Oleksandr Iegorov
committed
MAGETWO-97040: Magento Framework Escaper - Critical log with special symbols
1 parent f77f96b commit 847d20f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/internal/Magento/Framework/Escaper.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function ($errorNumber, $errorString) {
9191
throw new \Exception($errorString, $errorNumber);
9292
}
9393
);
94+
$data = $this->prepareUnescapedCharacters($data);
9495
$string = mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8');
9596
try {
9697
$domDocument->loadHTML(
@@ -119,6 +120,19 @@ function ($errorNumber, $errorString) {
119120
return $result;
120121
}
121122

123+
/**
124+
* Used to replace characters, that mb_convert_encoding will not process
125+
*
126+
* @param string $data
127+
* @return string|null
128+
*/
129+
private function prepareUnescapedCharacters(string $data): ?string
130+
{
131+
$patterns = ['/\&/u'];
132+
$replacements = ['&'];
133+
return \preg_replace($patterns, $replacements, $data);
134+
}
135+
122136
/**
123137
* Remove not allowed tags
124138
*

0 commit comments

Comments
 (0)