Issue #3311595 by fjgarlin, mfb, pooja saraah, colorfield, alexpott, Wim Leers, longwave: Html::transformRootRelativeUrlsToAbsolute() replaces "\r\n" with "
\n"

merge-requests/3220/head
xjm 2022-12-25 11:55:04 -06:00
parent 2193f7675d
commit 3589a503aa
No known key found for this signature in database
GPG Key ID: 206B0B8743BDF4C2
2 changed files with 10 additions and 0 deletions

View File

@ -279,6 +279,11 @@ class Html {
<body>!html</body>
</html>
EOD;
// PHP's \DOMDocument::saveXML() encodes carriage returns as &#13; so
// normalize all newlines to line feeds.
$html = str_replace(["\r\n", "\r"], "\n", $html);
// PHP's \DOMDocument serialization adds extra whitespace when the markup
// of the wrapping document contains newlines, so ensure we remove all
// newlines before injecting the actual HTML body to be processed.

View File

@ -390,6 +390,11 @@ class HtmlTest extends TestCase {
}
}
// Double-character carriage return should be normalized.
$data['line break with double special character'] = ["Test without links but with\r\nsome special characters", 'http://example.com', "Test without links but with\nsome special characters"];
$data['line break with single special character'] = ["Test without links but with&#13;\nsome special characters", 'http://example.com', FALSE];
$data['carriage return within html'] = ["<a\rhref='/node'>My link</a>", 'http://example.com', '<a href="http://example.com/node">My link</a>'];
return $data;
}