PHPMailer::setLanguage(): match language codes case-insensitively

For "language code - country code" locale notations, it is common for the "country code" part to be provided in uppercase, like `pt_BR`.

The method currently did not allow for that correctly. The regex check would accept the language code, but then fail to find the file on *nix based systems as the file names are all in lowercase and non-Windows file systems are generally case-sensitive. Which means that in effect, the method, ended up falling back to the default language (English).

The change in this commit makes the handling of the provided `$langcode` case-tolerant.

Note: the language code used in the file names for the language files is still expected to always be lowercase, including for language files in custom paths!

Related to 2418 - observation 1
This commit is contained in:
jrfnl 2021-07-08 10:51:14 +02:00
parent 9182613398
commit aaf18fd5b2
1 changed files with 2 additions and 1 deletions

View File

@ -2250,7 +2250,8 @@ class PHPMailer
//Validate $langcode
$foundlang = true;
if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode) && $langcode !== 'en') {
$langcode = strtolower($langcode);
if (!preg_match('/^[a-z]{2}(?:_[a-z]{2})?$/', $langcode) && $langcode !== 'en') {
$foundlang = false;
$langcode = 'en';
}