MDL-17518 resource names filter: Improve handling when name contains htmlentities() chars. Merged from 19_STABLE

This commit is contained in:
stronk7 2008-12-07 17:34:37 +00:00
parent a4f2b684d6
commit e6b3d18342

View File

@ -53,14 +53,22 @@
$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);
}
}
}