MDL-87482 core: Better text comparison
This commit is contained in:
@@ -329,8 +329,11 @@ class formatting {
|
||||
$domdoc->saveHTML($domdoc->documentElement),
|
||||
));
|
||||
// Libxml2 >= 2.14.0 doesn't wrap plain text in <p> tags, so add them for consistency.
|
||||
if (LIBXML_VERSION >= 21400 && !empty($text) && !preg_match('/^\s*</', $text)) {
|
||||
$text = '<p>' . $text . '</p>';
|
||||
if (LIBXML_VERSION >= 21400) {
|
||||
$trimmed = trim($text);
|
||||
if ($trimmed !== '' && !preg_match('/^</', $trimmed)) {
|
||||
$text = '<p>' . $text . '</p>';
|
||||
}
|
||||
}
|
||||
// The meta charset approach preserves leading/trailing whitespace in <p> tags more than the old XML
|
||||
// declaration approach. Normalize this by trimming whitespace inside <p> tags to match old behavior.
|
||||
|
||||
@@ -720,8 +720,11 @@ class helper {
|
||||
// Remove <body> element added in C14N function.
|
||||
$html = preg_replace('~<(/?(?:body))[^>]*>\s*~i', '', $html);
|
||||
// Libxml2 >= 2.14.0 doesn't wrap plain text in <p> tags, so add them for consistency.
|
||||
if (LIBXML_VERSION >= 21400 && !empty($html) && !preg_match('/^\s*</', $html)) {
|
||||
$html = '<p>' . $html . '</p>';
|
||||
if (LIBXML_VERSION >= 21400) {
|
||||
$trimmed = trim($html);
|
||||
if ($trimmed !== '' && !preg_match('/^</', $trimmed)) {
|
||||
$html = '<p>' . $html . '</p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user