[web-php] master: Normalize language code case in LangChooser (#1303)
| From: | Luffy via GitHub | Date: | Tue, 05 Aug 2025 01:09:22 +0000 |
| Subject: | [web-php] master: Normalize language code case in LangChooser (#1303) | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-33078@lists.php.net to get a copy of this message | ||
Author: Luffy (sy-records)
Committer: GitHub (web-flow)
Pusher: sy-records
Date: 2025-08-05T08:55:18+08:00
Commit: https://github.com/php/web-php/commit/19786a720f8d0a6b747533304f9936bb41d82d37
Raw diff: https://github.com/php/web-php/commit/19786a720f8d0a6b747533304f9936bb41d82d37.diff
Normalize language code case in LangChooser (#1303)
Changed paths:
M src/LangChooser.php
Diff:
diff --git a/src/LangChooser.php b/src/LangChooser.php
index 92ddb09de5..f889e14225 100644
--- a/src/LangChooser.php
+++ b/src/LangChooser.php
@@ -97,7 +97,7 @@ public function chooseCode(
// The language part is either a code or a code with a quality
// We cannot do anything with a * code, so it is skipped
// If the quality is missing, it is assumed to be 1 according to the RFC
- if (preg_match("!([a-z-]+)(;q=([0-9\\.]+))?!", trim($value), $found)) {
+ if (preg_match("!([a-z-]+)(;q=([0-9\\.]+))?!", strtolower(trim($value)),
$found)) {
$quality = (isset($found[3]) ? (float) $found[3] : 1.0);
$browser_langs[] = [$found[1], $quality];
}