fix(web/problem): not escape problem title
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-11-12 12:05:24 +08:00
parent 274baec200
commit aeb6628314
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 22 additions and 7 deletions

View File

@ -302,14 +302,29 @@ class HTML {
return $res; return $res;
} }
public static function link(?string $uri, $text, $cfg = ['location' => 'main']) { public static function link(?string $uri, $text, $cfg = []) {
$cfg += ['location' => 'main', 'escape' => true];
if ($cfg['escape']) {
$text = HTML::escape($text);
}
if ($uri === null) { if ($uri === null) {
return '<a>' . HTML::escape($text) . '</a>'; return HTML::tag('a', [], $text);
} }
return '<a class="text-decoration-none" href="' . HTML::url($uri, $cfg) . '">' . HTML::escape($text) . '</a>';
return HTML::tag('a', ['href' => HTML::url($uri, $cfg)], $text);
} }
public static function autolink(string $url, array $attr = []) {
return '<a class="text-decoration-none" href="' . $url . '"' . HTML::attr($attr) . '>' . $url . '</a>'; public static function autolink(string $url, array $attr = [], $cfg = []) {
$cfg += ['escape' => true];
$text = $url;
if ($cfg['escape']) {
$text = HTML::escape($text);
}
return '<a href="' . $url . '"' . HTML::attr($attr) . '>' . $text . '</a>';
} }
public static function js_src(string $uri, array $cfg = []) { public static function js_src(string $uri, array $cfg = []) {
$cfg += [ $cfg += [

View File

@ -83,7 +83,7 @@ class UOJProblem {
} }
public function getLink(array $cfg = []) { public function getLink(array $cfg = []) {
return HTML::link($this->getUri(), $this->getTitle($cfg)); return HTML::link($this->getUri(), $this->getTitle($cfg), ['escape' => false]);
} }
public function getAttachmentUri() { public function getAttachmentUri() {