mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 16:28:40 +00:00
fix: 8a7930e18c
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ea4cfd8376
commit
54b8415cf5
@ -144,8 +144,10 @@ class HTML {
|
|||||||
|
|
||||||
public static function purifier() {
|
public static function purifier() {
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
//$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
|
// $config->set('Cache.DefinitionImpl', null);
|
||||||
$config->set('Cache.DefinitionImpl', null);
|
$config->set('HTML.DefinitionID', 'UOJ__HTML::purifier()');
|
||||||
|
$config->set('HTML.DefinitionRev', 1);
|
||||||
|
$config->set('Output.Newline', true);
|
||||||
$def = $config->getHTMLDefinition(true);
|
$def = $config->getHTMLDefinition(true);
|
||||||
|
|
||||||
$def->addElement('section', 'Block', 'Flow', 'Common');
|
$def->addElement('section', 'Block', 'Flow', 'Common');
|
||||||
@ -155,6 +157,16 @@ class HTML {
|
|||||||
$def->addElement('header', 'Block', 'Flow', 'Common');
|
$def->addElement('header', 'Block', 'Flow', 'Common');
|
||||||
$def->addElement('footer', 'Block', 'Flow', 'Common');
|
$def->addElement('footer', 'Block', 'Flow', 'Common');
|
||||||
|
|
||||||
|
$extra_allowed_html = [
|
||||||
|
'span' => ['data-realname' => 'Text', 'data-uoj-username' => 'Number'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($extra_allowed_html as $element => $attributes) {
|
||||||
|
foreach ($attributes as $attribute => $type) {
|
||||||
|
$def->addAttribute($element, $attribute, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new HTMLPurifier($config);
|
return new HTMLPurifier($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,6 +184,7 @@ class HTML {
|
|||||||
'small' => [],
|
'small' => [],
|
||||||
'del' => [],
|
'del' => [],
|
||||||
'br' => [],
|
'br' => [],
|
||||||
|
'span' => ['data-realname' => 'Text', 'data-uoj-username' => 'Number'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
@ -181,7 +194,7 @@ class HTML {
|
|||||||
|
|
||||||
foreach ($allowed_html as $element => $attributes) {
|
foreach ($allowed_html as $element => $attributes) {
|
||||||
$allowed_elements[$element] = true;
|
$allowed_elements[$element] = true;
|
||||||
foreach ($attributes as $attribute => $x) {
|
foreach ($attributes as $attribute => $type) {
|
||||||
$allowed_attributes["$element.$attribute"] = true;
|
$allowed_attributes["$element.$attribute"] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,6 +202,17 @@ class HTML {
|
|||||||
$config->set('HTML.AllowedElements', $allowed_elements);
|
$config->set('HTML.AllowedElements', $allowed_elements);
|
||||||
$config->set('HTML.AllowedAttributes', $allowed_attributes);
|
$config->set('HTML.AllowedAttributes', $allowed_attributes);
|
||||||
|
|
||||||
|
// $config->set('Cache.DefinitionImpl', null);
|
||||||
|
$config->set('HTML.DefinitionID', 'UOJ__HTML::purifier_inline()');
|
||||||
|
$config->set('HTML.DefinitionRev', 1);
|
||||||
|
$def = $config->getHTMLDefinition(true);
|
||||||
|
|
||||||
|
foreach ($allowed_html as $element => $attributes) {
|
||||||
|
foreach ($attributes as $attribute => $type) {
|
||||||
|
$def->addAttribute($element, $attribute, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new HTMLPurifier($config);
|
return new HTMLPurifier($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,16 +54,16 @@ class UOJMarkdown extends ParsedownMath {
|
|||||||
// https://gist.github.com/ShNURoK42/b5ce8baa570975db487c
|
// https://gist.github.com/ShNURoK42/b5ce8baa570975db487c
|
||||||
protected function inlineUserMention($Excerpt) {
|
protected function inlineUserMention($Excerpt) {
|
||||||
if (preg_match('/^@([^\s]+)/', $Excerpt['text'], $matches)) {
|
if (preg_match('/^@([^\s]+)/', $Excerpt['text'], $matches)) {
|
||||||
if (validateUsername($matches[1]) && ($user = queryUser($matches[1]))) {
|
if (validateUsername($matches[1]) && ($user = queryUser($matches[1])) && $user['usergroup'] != 'B') {
|
||||||
return [
|
return [
|
||||||
'extent' => strlen($matches[0]),
|
'extent' => strlen($matches[0]),
|
||||||
'element' => [
|
'element' => [
|
||||||
'name' => 'a',
|
'name' => 'span',
|
||||||
'text' => '@' . $user['username'],
|
'text' => '@' . $user['username'],
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'href' => '/user/' . $user['username'],
|
|
||||||
'class' => 'uoj-username',
|
'class' => 'uoj-username',
|
||||||
'data-realname' => $user['realname'],
|
'data-realname' => $user['realname'],
|
||||||
|
'data-uoj-username' => 1,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -428,7 +428,7 @@ $(document).ready(function() {
|
|||||||
// highlight
|
// highlight
|
||||||
$.fn.uoj_highlight = function() {
|
$.fn.uoj_highlight = function() {
|
||||||
return $(this).each(function() {
|
return $(this).each(function() {
|
||||||
$(this).find("span.uoj-username").each(replaceWithHighlightUsername);
|
$(this).find("span.uoj-username, span[data-uoj-username]").each(replaceWithHighlightUsername);
|
||||||
$(this).find(".uoj-honor").uoj_honor();
|
$(this).find(".uoj-honor").uoj_honor();
|
||||||
$(this).find(".uoj-testcase").uoj_testcase();
|
$(this).find(".uoj-testcase").uoj_testcase();
|
||||||
$(this).find(".uoj-score").each(function() {
|
$(this).find(".uoj-score").each(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user