Permalink
Browse files

MDL-34654 Glossary: ampersand breaks auto-linking

  • Loading branch information...
1 parent 1115bb3 commit fb166770b9a83537f85bad8c03a5d3d474b41c9b @sammarshallou sammarshallou committed Oct 23, 2013
Showing with 11 additions and 2 deletions.
  1. +11 −2 filter/glossary/filter.php
View
@@ -131,6 +131,11 @@ public function filter($text, array $options = array()) {
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 @@ public function filter($text, array $options = array()) {
'&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.

0 comments on commit fb16677

Please sign in to comment.