Skip to content

Commit

Permalink
MDL-38055 course: fixed double encoding of title properties
Browse files Browse the repository at this point in the history
Conflicts:
	lib/navigationlib.php

Conflicts:
	blocks/course_overview/renderer.php
	lib/navigationlib.php
  • Loading branch information
Sam Hemelryk committed Mar 20, 2013
1 parent d43ba3c commit 4688b27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
5 changes: 4 additions & 1 deletion lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,7 @@ public function add_course(stdClass $course, $forcegeneric = false, $ismycourse

$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;
Expand Down Expand Up @@ -2559,7 +2560,9 @@ public function add_course(stdClass $course, $forcegeneric = false, $ismycourse
$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;
}
Expand Down

0 comments on commit 4688b27

Please sign in to comment.