Skip to content

Commit 1fc481d

Browse files
Damyon WieseJenkins
authored andcommitted
MDL-64651 comments: Do not send referrer
Use blanktarget option on all comments to prevent malicious links.
1 parent cd3060d commit 1fc481d

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

comment/classes/external.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public static function get_comments($contextlevel, $instanceid, $component, $ite
102102
if ($comments === false) {
103103
throw new moodle_exception('nopermissions', 'error', '', 'view comments');
104104
}
105+
$options = array('blanktarget' => true);
105106

106107
foreach ($comments as $key => $comment) {
107108

@@ -110,7 +111,8 @@ public static function get_comments($contextlevel, $instanceid, $component, $ite
110111
$context->id,
111112
$params['component'],
112113
'',
113-
0);
114+
0,
115+
$options);
114116
}
115117

116118
$results = array(

comment/lib.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ public function get_comments($page = '') {
570570
$params['itemid'] = $this->itemid;
571571

572572
$comments = array();
573-
$formatoptions = array('overflowdiv' => true);
573+
$formatoptions = array('overflowdiv' => true, 'blanktarget' => true);
574574
$rs = $DB->get_recordset_sql($sql, $params, $start, $perpage);
575575
foreach ($rs as $u) {
576576
$c = new stdClass();
@@ -717,7 +717,8 @@ public function add($content, $format = FORMAT_MOODLE) {
717717
$newcmt->fullname = fullname($USER);
718718
$url = new moodle_url('/user/view.php', array('id' => $USER->id, 'course' => $this->courseid));
719719
$newcmt->profileurl = $url->out();
720-
$newcmt->content = format_text($newcmt->content, $newcmt->format, array('overflowdiv'=>true));
720+
$formatoptions = array('overflowdiv' => true, 'blanktarget' => true);
721+
$newcmt->content = format_text($newcmt->content, $newcmt->format, $formatoptions);
721722
$newcmt->avatar = $OUTPUT->user_picture($USER, array('size'=>16));
722723

723724
$commentlist = array($newcmt);

comment/locallib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function get_comments($page) {
6868
ON u.id=c.userid
6969
ORDER BY c.timecreated ASC";
7070
$rs = $DB->get_recordset_sql($sql, null, $start, $this->perpage);
71-
$formatoptions = array('overflowdiv' => true);
71+
$formatoptions = array('overflowdiv' => true, 'blanktarget' => true);
7272
foreach ($rs as $item) {
7373
// Set calculated fields
7474
$item->fullname = fullname($item);

0 commit comments

Comments
 (0)