From d2e95acd75b79e9d9d3454f841e3eb6ab81021ec Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Sep 2026 18:43:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B0=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/modules/captcha.php | 1 - .../widget-system/admin-ui-contract.test.cjs | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/inc/modules/captcha.php b/inc/modules/captcha.php index 8de729fb..5f8479d8 100644 --- a/inc/modules/captcha.php +++ b/inc/modules/captcha.php @@ -37,7 +37,6 @@ function aksrt_captcha_scenes(): array { 'lostpassword' => __('找回密码', 'aksrt'), 'change_password' => __('修改密码', 'aksrt'), 'change_email' => __('更改邮箱', 'aksrt'), - 'verify_email' => __('邮箱验证', 'aksrt'), 'download' => __('资源下载', 'aksrt'), 'signin' => __('每日签到', 'aksrt'), 'front_submit' => __('前台投稿', 'aksrt'), diff --git a/tests/widget-system/admin-ui-contract.test.cjs b/tests/widget-system/admin-ui-contract.test.cjs index 33b5c004..a2170c0c 100644 --- a/tests/widget-system/admin-ui-contract.test.cjs +++ b/tests/widget-system/admin-ui-contract.test.cjs @@ -62,3 +62,23 @@ test('navigation, focus, responsive layout, and reduced motion are contracted', assert.match(styles, /@media \(max-width:\s*480px\)/) assert.match(styles, /@media \(prefers-reduced-motion:\s*reduce\)/) }) + +test('captcha scene whitelist matches both admin schemas and excludes dead email verification', () => { + const captcha = read('inc/modules/captcha.php') + const phpSchema = read('src/Admin/Schema/SchemaPermissions.php') + const jsSchema = read('assets/admin/src/schema/sections/permissions/index.js') + + assert.doesNotMatch(captcha, /'verify_email'\s*=>/) + assert.doesNotMatch(phpSchema, /'verify_email'/) + assert.doesNotMatch(jsSchema, /value:\s*'verify_email'/) + + const sceneBlock = captcha.match(/function aksrt_captcha_scenes\(\): array \{[\s\S]*?return \[([\s\S]*?)\n\t\];/) + const phpField = phpSchema.match(/'key' => 'enabled_scenarios'[\s\S]*?'options' => \[([\s\S]*?)\]\],/) + const jsField = jsSchema.match(/key: 'enabled_scenarios'[\s\S]*?options: \[([\s\S]*?)\n\s*\],/) + assert.ok(sceneBlock && phpField && jsField, 'captcha scene contracts must be discoverable') + + const values = (text, pattern) => [...text.matchAll(pattern)].map((match) => match[1]).sort() + const scenes = values(sceneBlock[1], /'([^']+)'\s*=>/g) + assert.deepStrictEqual(values(phpField[1], /'value'\s*=>\s*'([^']+)'/g), scenes) + assert.deepStrictEqual(values(jsField[1], /value:\s*'([^']+)'/g), scenes) +})