MDL-62042 core_search: Unicode non-characters cause indexing problems

Unicode characters such as U+FFEF can be entered into Moodle data and
cause indexing failures. This change strips them out of search fields.
This commit is contained in:
sam marshall
2018-04-19 16:54:47 +01:00
parent 6d4bc5bd34
commit ffa868a9e1
4 changed files with 99 additions and 0 deletions
+3
View File
@@ -291,6 +291,9 @@ class document implements \renderable, \templatable {
if ($fielddata['type'] === 'int' || $fielddata['type'] === 'tdate') {
$this->data[$fieldname] = intval($value);
} else {
// Remove disallowed Unicode characters.
$value = \core_text::remove_unicode_non_characters($value);
// Replace all groups of line breaks and spaces by single spaces.
$this->data[$fieldname] = preg_replace("/\s+/u", " ", $value);
if ($this->data[$fieldname] === null) {