-
Bug
-
Resolution: Fixed
-
Critical
-
3.1
-
MOODLE_31_STABLE
-
MOODLE_30_STABLE, MOODLE_31_STABLE
-
MDL-54853-master -
-
-
3.2 Sprint 1
After last weekly update, messages are not usable, because non-latin letters are broken during filter operation in "/lib/weblib.php" function "format_text", because of this part of the code:
if ($options['blanktarget']) {
|
$domdoc = new DOMDocument();
|
$domdoc->loadHTML($text);
|
foreach ($domdoc->getElementsByTagName('a') as $link) {
|
if ($link->hasAttribute('target') && strpos($link->getAttribute('target'), '_blank') === false) {
|
continue;
|
}
|
$link->setAttribute('target', '_blank');
|
if (strpos($link->getAttribute('rel'), 'noreferrer') === false) {
|
$link->setAttribute('rel', trim($link->getAttribute('rel') . ' noreferrer'));
|
}
|
}
|
|
// This regex is nasty and I don't like it. The correct way to solve this is by loading the HTML like so:
|
// $domdoc->loadHTML($text, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); however it seems like the libxml
|
// version that travis uses doesn't work properly and ends up leaving <html><body>, so I'm forced to use
|
// this regex to remove those tags.
|
$text = trim(preg_replace('~<(?:!DOCTYPE|/?(?:html|body))[^>]*>\s*~i', '', $domdoc->saveHTML()));
|
}
|