Use toString instead of html

The content saved to the database already encodes content that needs
encoding, e.g. <script> tags. The problem with pQuery's `html` method is
 it decodes everything. By using toString instead, we should be getting
 the same contents that were saved to the database.

MAILPOET-5632
This commit is contained in:
John Oleksowicz
2023-10-10 10:22:30 -05:00
committed by Aschepikov
parent efc80b0476
commit dae1cb19a8
2 changed files with 38 additions and 3 deletions

View File

@@ -38,7 +38,7 @@ class Text {
if (preg_match('/h\d/', $paragraph->getTag())) {
$contents[] = $paragraph->getOuterText();
} else {
$contents[] = str_replace('&', '&amp;', $paragraph->html());
$contents[] = $paragraph->toString(true, true, 1);
}
if ($index + 1 < $paragraphs->count()) $contents[] = '<br />';
$paragraph->remove();
@@ -105,7 +105,7 @@ class Text {
if (!preg_match('/text-align/i', $style)) {
$style = 'text-align: left;' . $style;
}
$contents = str_replace('&', '&amp;', $paragraph->html());
$contents = $paragraph->toString(true, true, 1);
$paragraph->setTag('table');
$paragraph->style = 'border-spacing:0;mso-table-lspace:0;mso-table-rspace:0;';
$paragraph->width = '100%';
@@ -144,7 +144,7 @@ class Text {
if (!$lists->count()) return $html;
foreach ($lists as $list) {
if ($list->tag === 'li') {
$list->setInnertext(str_replace('&', '&amp;', $list->html()));
$list->setInnertext($list->toString(true, true, 1));
$list->class = 'mailpoet_paragraph';
} else {
$list->class = 'mailpoet_paragraph';