fix(captcha): 防止空 captcha_id 请求极验 403

custom 类型 schema 现按 array 深度净化保存;前台启用但凭据未齐时跳过渲染,Geetest 客户端也校验 captchaId。
This commit is contained in:
2026-07-12 14:49:24 +08:00
parent 4fe4d79da0
commit b7dc3d170d
2 changed files with 97 additions and 15 deletions
@@ -365,7 +365,24 @@ class AKSRT_Admin_Schema_Provider {
case 'float':
return (float) $value;
case 'array':
return is_array($value) ? $value : [];
// 深层字符串净化,保留嵌套服务商配置(如 geetest.captcha_id)
if (!is_array($value)) {
return [];
}
$out = [];
foreach ($value as $k => $v) {
$key = is_string($k) ? sanitize_key($k) : $k;
if (is_array($v)) {
$out[$key] = $this->sanitize_value($v, 'array');
} elseif (is_bool($v)) {
$out[$key] = $v;
} elseif (is_int($v) || is_float($v)) {
$out[$key] = $v;
} else {
$out[$key] = sanitize_text_field((string) $v);
}
}
return $out;
default:
return sanitize_text_field((string) $value);
}
@@ -383,6 +400,8 @@ class AKSRT_Admin_Schema_Provider {
'radio' => 'string',
'checkbox' => 'array',
'repeater' => 'array',
// 自定义面板(验证码服务商等)按对象存储
'custom' => 'array',
'color' => 'string',
'icon' => 'string',
'media' => 'url',