From a42e26b41810c2fe4771715be8cd1165843fabbd Mon Sep 17 00:00:00 2001 From: Yulong Ming Date: Tue, 7 Jul 2026 02:44:13 +0800 Subject: [PATCH 1/3] fix: read WHITELIST from $_ENV so it works on Vercel The vercel-php runtime exposes env vars via $_ENV/getenv() rather than $_SERVER, matching how TOKEN is already read. Fixes #911. --- src/whitelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/whitelist.php b/src/whitelist.php index 21114834..e8594197 100644 --- a/src/whitelist.php +++ b/src/whitelist.php @@ -8,6 +8,6 @@ */ function isWhitelisted(string $user): bool { - $whitelist = array_map("trim", array_filter(explode(",", $_SERVER["WHITELIST"] ?? ""))); + $whitelist = array_map("trim", array_filter(explode(",", $_ENV["WHITELIST"] ?? ""))); return empty($whitelist) || in_array($user, $whitelist, true); } From 97f35352281ed56e709ff9f2c2dd16a1ea4a6e9c Mon Sep 17 00:00:00 2001 From: Yulong Ming Date: Tue, 7 Jul 2026 16:42:59 +0800 Subject: [PATCH 2/3] Lookup both $_ENV and $_SERVER for env WHITELIST Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/whitelist.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/whitelist.php b/src/whitelist.php index e8594197..35328245 100644 --- a/src/whitelist.php +++ b/src/whitelist.php @@ -8,6 +8,7 @@ */ function isWhitelisted(string $user): bool { - $whitelist = array_map("trim", array_filter(explode(",", $_ENV["WHITELIST"] ?? ""))); + $whitelistRaw = $_ENV["WHITELIST"] ?? $_SERVER["WHITELIST"] ?? (getenv("WHITELIST") ?: ""); + $whitelist = array_map("trim", array_filter(explode(",", $whitelistRaw))); return empty($whitelist) || in_array($user, $whitelist, true); } From f451faf07778ca94822eaab0515f591b45b87d07 Mon Sep 17 00:00:00 2001 From: Yulong Ming Date: Thu, 16 Jul 2026 07:29:19 +0800 Subject: [PATCH 3/3] Use a strict === false check on getenv() for check of unset vars Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/whitelist.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/whitelist.php b/src/whitelist.php index 35328245..fb528636 100644 --- a/src/whitelist.php +++ b/src/whitelist.php @@ -8,7 +8,11 @@ */ function isWhitelisted(string $user): bool { - $whitelistRaw = $_ENV["WHITELIST"] ?? $_SERVER["WHITELIST"] ?? (getenv("WHITELIST") ?: ""); + $whitelistRaw = $_ENV["WHITELIST"] ?? $_SERVER["WHITELIST"] ?? null; + if ($whitelistRaw === null) { + $whitelistRaw = getenv("WHITELIST"); + $whitelistRaw = $whitelistRaw === false ? "" : $whitelistRaw; + } $whitelist = array_map("trim", array_filter(explode(",", $whitelistRaw))); return empty($whitelist) || in_array($user, $whitelist, true); }