Skip to content

Commit

Permalink
TW21240098, Improved comments processing (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichPound authored Feb 17, 2025
1 parent d2b5f0f commit f05dd15
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion classes/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function save() {
global $DB, $USER;

$this->timemodified = time();
$this->content = html_to_text($this->content, 5000, false);
$this->content = clean_param(html_to_text($this->content, 5000, false), PARAM_TEXT);

if ($this->id > 0) {
$DB->update_record('board_comments', $this);
Expand Down
11 changes: 11 additions & 0 deletions classes/tables/comments_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ public function other_cols($colname, $value) {
}
}

/**
* Format each row of returned data.
*
* @param array|object $row row of data from db used to make one row of the table.
* @return array one row for the table with sanitised content.
*/
public function format_row($row): array {
$row->content = clean_param($row->content, PARAM_TEXT);
return parent::format_row($row);
}

/**
* Displays the table.
*/
Expand Down
2 changes: 1 addition & 1 deletion external.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ public static function get_comments($noteid) {
$comment = (object)[];
$comment->id = $note->id;
$comment->noteid = $note->noteid;
$comment->content = $note->content;
$comment->content = clean_param($note->content, PARAM_TEXT);
$comment->candelete = (($canpost && $note->userid === $USER->id) || $candeleteall) ? true : false;
$comment->date = userdate($note->timecreated);
$comments[] = $comment;
Expand Down

0 comments on commit f05dd15

Please sign in to comment.