Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issues with broken HTML entities in warning templates #8214

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading