diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp index dbc2273f329..a4074a43850 100644 --- a/ext/intl/dateformat/dateformat_create.cpp +++ b/ext/intl/dateformat/dateformat_create.cpp @@ -112,8 +112,8 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin } locale = Locale::createFromName(locale_str); /* get*Name accessors being set does not preclude being bogus */ - if (locale.isBogus() || strlen(locale.getISO3Language()) == 0) { - zend_argument_value_error(1, "\"%s\" is invalid", locale_str); + if (locale.isBogus() || ((locale_len == 1 && locale_str[0] != 'C') && strlen(locale.getISO3Language()) == 0)) { + zend_argument_value_error(1, "\"%s\" is invalid", locale_str); return FAILURE; } diff --git a/ext/intl/tests/gh12943.phpt b/ext/intl/tests/gh12943.phpt new file mode 100644 index 00000000000..1a8856640ac --- /dev/null +++ b/ext/intl/tests/gh12943.phpt @@ -0,0 +1,15 @@ +--TEST-- +GitHub #12943 IntlDateFormatter::locale accepting "C". +--EXTENSIONS-- +intl +--FILE-- +getLocale(ULOC_VALID_LOCALE)); +--EXPECTF-- +string(%d) "%s"