MDL-34654 Glossary: ampersand breaks auto-linking

This commit is contained in:
sam marshall
2013-10-23 16:22:25 +01:00
parent e81fce929a
commit d1b0786a51
+11 -2
View File
@@ -131,6 +131,11 @@ class filter_glossary extends moodle_text_filter {
foreach ($concepts as $key => $concept) {
// Trim empty or unlinkable concepts
$currentconcept = trim(strip_tags($concept->concept));
// Concept must be HTML-escaped, so do the same as print_string
// to turn ampersands into &.
$currentconcept = replace_ampersands_not_followed_by_entity($currentconcept);
if (empty($currentconcept)) {
unset($concepts[$key]);
continue;
@@ -168,10 +173,14 @@ class filter_glossary extends moodle_text_filter {
'&mode=cat&hook='.$concept->id.'">';
} else { // Link to entry or alias
if (!empty($concept->originalconcept)) { // We are dealing with an alias (so show and point to original)
$title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->originalconcept));
$title = str_replace('"', "'", html_entity_decode(
strip_tags($glossaryname.': '.$concept->originalconcept)));
$concept->id = $concept->entryid;
} else { // This is an entry
$title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->concept));
// We need to remove entities from the content here because it
// will be escaped by html_writer below.
$title = str_replace('"', "'", html_entity_decode(
strip_tags($glossaryname.': '.$concept->concept)));
}
// hardcoding dictionary format in the URL rather than defaulting
// to the current glossary format which may not work in a popup.