Skip to content

Commit

Permalink
Merge pull request #8214 from Sesquipedalian/warning_template_htmlspe…
Browse files Browse the repository at this point in the history
…cialchars

Fixes issues with broken HTML entities in warning templates
  • Loading branch information
Sesquipedalian committed May 21, 2024
2 parents 209c62b + e3e3359 commit a140813
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Sources/ModerationCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,8 @@ function ModifyWarningTemplate()
{
$context['template_data'] = array(
'title' => $row['template_title'],
'body' => $smcFunc['htmlspecialchars']($row['body']),
// Redo htmlspecialchars for the sake of old data that might have incorrectly encoded entities.
'body' => $smcFunc['htmlspecialchars'](un_htmlspecialchars($row['body'])),
'personal' => $row['id_recipient'],
'can_edit_personal' => $row['id_member'] == $user_info['id'],
);
Expand All @@ -1734,6 +1735,7 @@ function ModifyWarningTemplate()
{
// Safety first.
$_POST['template_title'] = $smcFunc['htmlspecialchars']($_POST['template_title']);
$_POST['template_body'] = $smcFunc['htmlspecialchars']($_POST['template_body']);

// Clean up BBC.
preparsecode($_POST['template_body']);
Expand Down
3 changes: 2 additions & 1 deletion Sources/Profile-Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,8 @@ function issueWarning($memID)

$context['notification_templates'][] = array(
'title' => $row['template_title'],
'body' => $row['body'],
// un_htmlspecialchars because this will be passed through JavaScriptEscape()
'body' => un_htmlspecialchars($row['body']),
);
}
$smcFunc['db_free_result']($request);
Expand Down
2 changes: 1 addition & 1 deletion Themes/default/Profile.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@ function populateNotifyTemplate()
foreach ($context['notification_templates'] as $k => $type)
echo '
if (index == ', $k, ')
document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";';
document.getElementById(\'warn_body\').value = ', JavaScriptEscape($type['body']), ';';

echo '
}
Expand Down

0 comments on commit a140813

Please sign in to comment.