Commit 1d40291632f for php
commit 1d40291632f1f24e060912040b87abc994d44630
Merge: 258db32fb5a 7488547c556
Author: David Carlier <devnexen@gmail.com>
Date: Sun Dec 6 15:33:01 2026 +0000
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
ext/intl: reject invalid locales in IntlDatePatternGenerator
diff --cc ext/intl/dateformat/datepatterngenerator_methods.cpp
index beaf10d9f50,b164a7345ee..9e2a271cf9b
--- a/ext/intl/dateformat/datepatterngenerator_methods.cpp
+++ b/ext/intl/dateformat/datepatterngenerator_methods.cpp
@@@ -56,6 -61,11 +56,11 @@@ static zend_result dtpg_ctor(INTERNAL_F
locale_str = (char *) intl_locale_get_default();
}
Locale locale = Locale::createFromName(locale_str);
+ if (locale.isBogus()) {
+ intl_errors_set(DTPATTERNGEN_ERROR_P(dtpgo), U_ILLEGAL_ARGUMENT_ERROR,
- "Invalid locale", 0);
++ "Invalid locale");
+ return FAILURE;
+ }
dtpgo->dtpg = DateTimePatternGenerator::createInstance(
locale,
diff --cc ext/intl/tests/datepatterngenerator_invalid_locale.phpt
index 00000000000,cae33adc0d3..1e16db985b7
mode 000000,100644..100644
--- a/ext/intl/tests/datepatterngenerator_invalid_locale.phpt
+++ b/ext/intl/tests/datepatterngenerator_invalid_locale.phpt
@@@ -1,0 -1,17 +1,17 @@@
+ --TEST--
+ IntlDatePatternGenerator: invalid locale is rejected
+ --EXTENSIONS--
+ intl
+ --FILE--
+ <?php
+ try {
+ new IntlDatePatternGenerator('aaaaaaaaaaaa');
+ } catch (IntlException $e) {
+ echo $e->getMessage(), "\n";
+ }
+
+ var_dump(IntlDatePatternGenerator::create('aaaaaaaaaaaa'));
+ ?>
+ --EXPECT--
-Invalid locale: U_ILLEGAL_ARGUMENT_ERROR
++IntlDatePatternGenerator::__construct(): Invalid locale
+ NULL