From 4688b27ab34ba6182522918eb997d7092003ae78 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 20 Mar 2013 17:27:08 +1300 Subject: [PATCH] MDL-38055 course: fixed double encoding of title properties Conflicts: lib/navigationlib.php Conflicts: blocks/course_overview/renderer.php lib/navigationlib.php --- course/lib.php | 4 +++- lib/navigationlib.php | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/course/lib.php b/course/lib.php index f7842ee582d..e00b1c08d34 100644 --- a/course/lib.php +++ b/course/lib.php @@ -857,7 +857,9 @@ function print_overview($courses, array $remote_courses=array()) { foreach ($courses as $course) { $fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id))); echo $OUTPUT->box_start('coursebox'); - $attributes = array('title' => s($fullname)); + // decode &'s. format_string above will have encoded them and html_writer will encode again when it processed the title + // attribute leading to double encoding. + $attributes = array('title' => str_replace('&', '&', $fullname)); if (empty($course->visible)) { $attributes['class'] = 'dimmed'; } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index f8709a72e67..58090ce5710 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2524,6 +2524,7 @@ class global_navigation extends navigation_node { $issite = ($course->id == $SITE->id); $shortname = format_string($course->shortname, true, array('context' => $coursecontext)); + $fullname = format_string($course->fullname, true, array('context' => $coursecontext)); if ($issite) { $parent = $this; @@ -2559,7 +2560,9 @@ class global_navigation extends navigation_node { $coursenode = $parent->add($shortname, $url, self::TYPE_COURSE, $shortname, $course->id); $coursenode->nodetype = self::NODETYPE_BRANCH; $coursenode->hidden = (!$course->visible); - $coursenode->title(format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)))); + // We need to decode &'s here as they will have been added by format_string above and attributes will be encoded again + // later. + $coursenode->title(str_replace('&', '&', $fullname)); if (!$forcegeneric) { $this->addedcourses[$course->id] = $coursenode; }