Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 3.1
-
Component/s: Messages
-
Labels:
-
Testing Instructions:
-
Workaround:
-
Affected Branches:MOODLE_31_STABLE
-
Fixed Branches:MOODLE_30_STABLE, MOODLE_31_STABLE
-
Pull from Repository:
-
Pull Master Branch:
MDL-54853-master -
Pull Master Diff URL:
-
Sprint:3.2 Sprint 1
Description
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()));
|
}
|