Permalink
Browse files

MDL-17518 resource names filter: Improve handling when name contains …

…htmlentities() chars. Backported from HEAD
  • Loading branch information...
1 parent 11c82f1 commit e31d919deb9e0577b75a32216b7529746839908c stronk7 committed Dec 7, 2008
Showing with 11 additions and 3 deletions.
  1. +11 −3 mod/resource/filter.php
View
@@ -42,14 +42,22 @@ function resource_filter($courseid, $text) {
$resourcelist = array();
foreach ($resources as $resource) {
- $currentname = trim($resource->name);
- $strippedname = strip_tags($currentname);
+ $currentname = trim($resource->name);
+ $entitisedname = s($currentname);
+ $strippedname = strip_tags($currentname);
/// Avoid empty or unlinkable resource names
if (!empty($strippedname)) {
$resourcelist[] = new filterobject($currentname,
'<a class="resource autolink" title="'.$strippedname.'" href="'.
- $CFG->wwwroot.'/mod/resource/view.php?r='.$resource->id.'" '.$CFG->frametarget.'>',
+ $CFG->wwwroot.'/mod/resource/view.php?r='.$resource->id.'" '.$CFG->frametarget.'>',
'</a>', false, true);
+ if ($currentname != $entitisedname) { /// If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17518
+ $resourcelist[] = new filterobject($entitisedname,
+ '<a class="resource autolink" title="'.$strippedname.'" href="'.
+ $CFG->wwwroot.'/mod/resource/view.php?r='.$resource->id.'" '.$CFG->frametarget.'>',
+ '</a>', false, true);
+
+ }
}
}

0 comments on commit e31d919

Please sign in to comment.