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.<code>) remain lowercase since that is the on-disk key.
This commit is contained in:
Damodar Lohani committed 2026-07-06 02:25:22 +00:00
1 parent f5cc846913
commit 54cc90ab27
2 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -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);
}
+3 -3
View File
@@ -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