mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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:
1 parent
f5cc846913
commit
54cc90ab27
2 files changed
+5
-5
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user