Skip to content

Commit 51f0445

Browse files
committed
Merge branch 'develop' of https://github.com/magento-commerce/magento2-page-builder into PR-2023-02-24
2 parents 5e89f0e + 64fd0a7 commit 51f0445

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

app/code/Magento/PageBuilder/Model/Dom/Element.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function querySelectorAll(string $selector): HtmlCollectionInterface
145145
public function removeStyle(string $styleProperty): string
146146
{
147147
$style = $this->getAttribute('style');
148-
$this->setAttribute('style', preg_replace("/${styleProperty}:(.*?);/", '', $style ?? ''));
148+
$this->setAttribute('style', preg_replace("/{$styleProperty}:(.*?);/", '', $style ?? ''));
149149
return $this->getAttribute('style') ?? '';
150150
}
151151

@@ -155,7 +155,7 @@ public function removeStyle(string $styleProperty): string
155155
public function addStyle(string $styleProperty, string $value): string
156156
{
157157
$this->removeStyle($styleProperty);
158-
$this->setAttribute('style', "${styleProperty}: $value; " . $this->getAttribute('style') ?? '');
158+
$this->setAttribute('style', "{$styleProperty}: $value; " . $this->getAttribute('style') ?? '');
159159
return $this->getAttribute('style') ?? '';
160160
}
161161
}

app/code/Magento/PageBuilder/Model/Filter/Template.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,12 @@ function ($errorNumber, $errorString) {
170170
throw new DOMException($errorString, $errorNumber);
171171
}
172172
);
173-
$string = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
173+
$convmap = [0x80, 0x10FFFF, 0, 0x1FFFFF];
174+
$string = mb_encode_numericentity(
175+
$html,
176+
$convmap,
177+
'UTF-8'
178+
);
174179
try {
175180
libxml_use_internal_errors(true);
176181
// LIBXML_SCHEMA_CREATE option added according to this message

app/code/Magento/PageBuilder/Model/Stage/HtmlFilter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ public function __construct(
4141
public function filterHtml(string $content): string
4242
{
4343
$dom = new \DOMDocument('1.0', 'UTF-8');
44+
$previous = '';
4445
try {
4546
//this code is required because of https://bugs.php.net/bug.php?id=60021
4647
$previous = libxml_use_internal_errors(true);
4748
$content = '<div>' . $content . '</div>';
48-
$string = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
49+
$convmap = [0x80, 0x10FFFF, 0, 0x1FFFFF];
50+
$string = mb_encode_numericentity(
51+
$content,
52+
$convmap,
53+
'UTF-8'
54+
);
4955
$dom->loadHTML($string, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
5056
} catch (\Exception $e) {
5157
$this->loggerInterface->critical($e->getMessage());

app/code/Magento/PageBuilder/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"magento/module-require-js": "*",
2323
"magento/module-media-storage": "*",
2424
"php": "~8.1.0||~8.2.0",
25-
"phpgt/dom": "2.2.3"
25+
"phpgt/dom": "^2.2"
2626
},
2727
"suggest": {
2828
"magento/module-review": "*"

0 commit comments

Comments
 (0)