From 7ebdcac181bfea8a6e3ba2e86bd5ccca821767cb Mon Sep 17 00:00:00 2001 From: TomyJan Date: Fri, 30 Jan 2026 17:27:48 +0800 Subject: [PATCH] Update app/service/OptimizeService.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- app/service/OptimizeService.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/service/OptimizeService.php b/app/service/OptimizeService.php index 3aee33b..fc07074 100644 --- a/app/service/OptimizeService.php +++ b/app/service/OptimizeService.php @@ -85,6 +85,14 @@ class OptimizeService } $proxy = config_get('optimize_ip_proxy', ''); if (!empty($proxy)) { + $proxy = trim($proxy); + if (filter_var($proxy, FILTER_VALIDATE_URL) === false) { + throw new Exception('无效的代理地址配置:URL 格式错误'); + } + $scheme = parse_url($proxy, PHP_URL_SCHEME); + if (!in_array($scheme, ['http', 'https'], true)) { + throw new Exception('无效的代理地址配置:仅支持 http 和 https 协议'); + } $url = rtrim($proxy, '/') . '/xingpingcn/enhanced-FaaS-in-China/refs/heads/main/Cf.json'; } else { $url = 'https://raw.githubusercontent.com/xingpingcn/enhanced-FaaS-in-China/refs/heads/main/Cf.json';