fix: DOMPurify on user self review page

This commit is contained in:
Baoshuo Ren 2022-09-20 10:17:28 +08:00
parent db75573e1f
commit ad9bbf9222
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -67,7 +67,7 @@
$result .= '<td><div id="' . $problem_review_id . '"></div></td>'; $result .= '<td><div id="' . $problem_review_id . '"></div></td>';
$esc_problem_self_review = rawurlencode($problem_self_review != null ? $problem_self_review['content'] : ''); $esc_problem_self_review = rawurlencode($problem_self_review != null ? $problem_self_review['content'] : '');
$result .= '<script type="text/javascript">' $result .= '<script type="text/javascript">'
. "$(function() { $('#$problem_review_id').html(DOMPurify.sanitize('{$esc_problem_self_review}', $dom_sanitize_config)); });" . "$(function() { $('#$problem_review_id').html(DOMPurify.sanitize(decodeURIComponent(\"{$esc_problem_self_review}\"), $dom_sanitize_config)); });"
. '</script>'; . '</script>';
if ($i == 0) { if ($i == 0) {
@ -76,7 +76,7 @@
$esc_contest_self_review = rawurlencode($contest_self_review != null ? $contest_self_review['content'] : ''); $esc_contest_self_review = rawurlencode($contest_self_review != null ? $contest_self_review['content'] : '');
$result .= '<td rowspan="' . $n_contest_problems . '"><div id="' . $contest_review_id . '"></div></td>'; $result .= '<td rowspan="' . $n_contest_problems . '"><div id="' . $contest_review_id . '"></div></td>';
$result .= '<script type="text/javascript">' $result .= '<script type="text/javascript">'
. "$(function() { $('#$contest_review_id').html(DOMPurify.sanitize('{$esc_contest_self_review}', $dom_sanitize_config)); });" . "$(function() { $('#$contest_review_id').html(DOMPurify.sanitize(decodeURIComponent(\"{$esc_contest_self_review}\"), $dom_sanitize_config)); });"
. '</script>'; . '</script>';
} }