From a9e80e7c3b297748c4a196845ce4fe370c6da79f Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 13 Mar 2023 17:20:14 +0800 Subject: [PATCH] fix(problem/remote/new): atcoder problem id --- web/app/controllers/new_remote_problem.php | 8 ++++---- web/app/libs/uoj-validate-lib.php | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/app/controllers/new_remote_problem.php b/web/app/controllers/new_remote_problem.php index 3ab1497..6af5b90 100644 --- a/web/app/controllers/new_remote_problem.php +++ b/web/app/controllers/new_remote_problem.php @@ -28,8 +28,8 @@ $new_remote_problem_form->addInput('remote_problem_id', [ } else if ($remote_oj === 'atcoder') { $id = trim(strtolower($id)); - if (!validateString($id)) { - return '不合法的题目 ID'; + if (!validateAtCoderProblemId($id)) { + return '不合法的字符串'; } $vdata['remote_problem_id'] = $id; @@ -149,10 +149,10 @@ $new_remote_problem_form->runAtServer();
  • 在导入题目前请先搜索题库中是否已经存在相应题目,避免重复添加。
  • diff --git a/web/app/libs/uoj-validate-lib.php b/web/app/libs/uoj-validate-lib.php index 73f4173..c2eb752 100644 --- a/web/app/libs/uoj-validate-lib.php +++ b/web/app/libs/uoj-validate-lib.php @@ -121,6 +121,10 @@ function validateCodeforcesProblemId($str) { return preg_match('/^(|GYM)[1-9][0-9]{0,5}[A-Z][1-9]?$/', $str); } +function validateAtCoderProblemId($str) { + return preg_match('/^(\w+)([a-z][1-9]?)$/', $str); +} + function validateLuoguProblemId($str) { return preg_match('/^P[1-9][0-9]{3,5}$/', $str); }