From 54cc90ab2794354786d011869846167fc53438be Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 6 Jul 2026 02:25:22 +0000 Subject: [PATCH] fix(geo): return uppercase countryCode to restore MaxMind parity MaxMind returned all region codes uppercase; the GeoRecord introduced in this PR was returning countryCode lowercase while continentCode stayed uppercase. That silently broke the public /v1/locale response, the x-appwrite-country-code function header, and asymmetrically shaped GeoRecord's API. Return countryCode uppercase and normalize the console denylist comparison to uppercase on both sides. Internal locale lookup keys (countries.) remain lowercase since that is the on-disk key. --- app/controllers/shared/api/auth.php | 4 ++-- src/Appwrite/Locale/GeoRecord.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/shared/api/auth.php b/app/controllers/shared/api/auth.php index 7b65f8602c..a8ad13e043 100644 --- a/app/controllers/shared/api/auth.php +++ b/app/controllers/shared/api/auth.php @@ -52,8 +52,8 @@ Http::init() throw new Exception(Exception::GENERAL_REGION_ACCESS_DENIED); } - $countries = \array_map('strtolower', \array_map('trim', explode(',', $denylist))); - $country = strtolower($geoRecord->getCountryCode()); + $countries = \array_map('strtoupper', \array_map('trim', explode(',', $denylist))); + $country = \strtoupper($geoRecord->getCountryCode()); if (in_array($country, $countries, true)) { throw new Exception(Exception::GENERAL_REGION_ACCESS_DENIED); } diff --git a/src/Appwrite/Locale/GeoRecord.php b/src/Appwrite/Locale/GeoRecord.php index b05951ab51..90477666b0 100644 --- a/src/Appwrite/Locale/GeoRecord.php +++ b/src/Appwrite/Locale/GeoRecord.php @@ -53,13 +53,13 @@ class GeoRecord extends Document return '--'; } - $lower = \strtolower($code); + $upper = \strtoupper($code); if ($this->locale === null) { - return $lower; + return $upper; } - return $this->locale->getText('countries.' . $lower, false) ? $lower : '--'; + return $this->locale->getText('countries.' . \strtolower($upper), false) ? $upper : '--'; } public function getCountryName(): string