Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ PHP NEWS
argument handling now raises TypeError instead of Error. (Weilin Du)
. IntlBreakIterator::getLocale() now raises ValueError for invalid locale
types. (Weilin Du)
. Fixed MessageFormatter::parse() and parseMessage() returning PHP_INT_MIN
as float rather than int on 64-bit platforms. (Weilin Du)

- JSON:
. Enriched JSON last error / exception message with error location.
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ PHP 8.6 UPGRADE NOTES
. IntlBreakIterator::getLocale() now raises a ValueError when the type is
neither Locale::ACTUAL_LOCALE nor Locale::VALID_LOCALE instead of
returning false.
. MessageFormatter::parse() and parseMessage() now return PHP_INT_MIN as
int, rather than float, on 64-bit platforms when parsing integer values.

- PCNTL:
. pcntl_alarm() now raises a ValueError if the seconds argument is
Expand Down
2 changes: 1 addition & 1 deletion ext/curl/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if (PHP_CURL != "no") {
CHECK_LIB("libssh2.lib", "curl", PHP_CURL) &&
CHECK_LIB("nghttp2.lib", "curl", PHP_CURL))
) {
if (!(CHECK_HEADER_ADD_INCLUDE("brotli/decode.h", "CFLAGS_CURL") &&
if (!(CHECK_HEADER("brotli/decode.h", "CFLAGS_CURL") &&
CHECK_LIB("brotlidec.lib;brotlidec-static.lib", "curl", PHP_CURL) &&
CHECK_LIB("brotlicommon.lib;brotlicommon-static.lib", "curl", PHP_CURL)
)) {
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/calendar/calendar_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ U_CFUNC PHP_FUNCTION(intlcal_get_available_locales)

int32_t count;
const Locale *availLocales = Calendar::getAvailableLocales(count);
array_init(return_value);
array_init_size(return_value, count);
for (int i = 0; i < count; i++) {
Locale locale = availLocales[i];
add_next_index_string(return_value, locale.getName());
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/dateformat/dateformat_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static void internal_parse_to_localtime(IntlDateFormatter_object *dfo, char* tex
INTL_METHOD_CHECK_STATUS( dfo, "Date parsing failed" );


array_init( return_value );
array_init_size( return_value, 9 );
/* Add entries from various fields of the obtained parsed_calendar */
add_to_localtime_arr( dfo, return_value, parsed_calendar, UCAL_SECOND, CALENDAR_SEC);
add_to_localtime_arr( dfo, return_value, parsed_calendar, UCAL_MINUTE, CALENDAR_MIN);
Expand Down
8 changes: 5 additions & 3 deletions ext/intl/listformatter/listformatter_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ PHP_METHOD(IntlListFormatter, format)
Z_PARAM_ARRAY_HT(ht)
ZEND_PARSE_PARAMETERS_END();

intl_errors_reset(LISTFORMATTER_ERROR_P(obj));

uint32_t count = zend_hash_num_elements(ht);
if (count == 0) {
RETURN_EMPTY_STRING();
Expand All @@ -152,7 +154,7 @@ PHP_METHOD(IntlListFormatter, format)
zend_tmp_string_release(tmp_str);

if (U_FAILURE(conv_status)) {
intl_error_set(nullptr, conv_status, "Failed to convert string to UTF-16");
intl_errors_set(LISTFORMATTER_ERROR_P(obj), conv_status, "Failed to convert string to UTF-16");
RETURN_FALSE;
}

Expand All @@ -165,14 +167,14 @@ PHP_METHOD(IntlListFormatter, format)
LISTFORMATTER_OBJECT(obj)->format(items.get(), count, result, status);

if (U_FAILURE(status)) {
intl_error_set(nullptr, status, "Failed to format list");
intl_errors_set(LISTFORMATTER_ERROR_P(obj), status, "Failed to format list");
RETURN_FALSE;
}

zend_string *ret = intl_charFromString(result, &status);

if (!ret) {
intl_error_set(nullptr, status, "Failed to convert result to UTF-8");
intl_errors_set(LISTFORMATTER_ERROR_P(obj), status, "Failed to convert result to UTF-8");
RETURN_FALSE;
}

Expand Down
14 changes: 7 additions & 7 deletions ext/intl/locale/locale_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static zend_string* get_icu_value_internal( const char* loc_name , const char* t
efree( mod_loc_name);
}

tag_value->len = strlen(tag_value->val);
tag_value->len = buflen;
return tag_value;
}
/* }}} */
Expand Down Expand Up @@ -736,7 +736,7 @@ U_CFUNC PHP_FUNCTION( locale_get_keywords )
Z_PARAM_PATH(loc_name, loc_name_len)
ZEND_PARSE_PARAMETERS_END();

INTL_CHECK_LOCALE_LEN(strlen(loc_name));
INTL_CHECK_LOCALE_LEN(loc_name_len);

if(loc_name_len == 0) {
loc_name = (char *)intl_locale_get_default();
Expand Down Expand Up @@ -1127,7 +1127,7 @@ U_CFUNC PHP_FUNCTION(locale_parse)
Z_PARAM_PATH(loc_name, loc_name_len)
ZEND_PARSE_PARAMETERS_END();

INTL_CHECK_LOCALE_LEN(strlen(loc_name));
INTL_CHECK_LOCALE_LEN(loc_name_len);

if(loc_name_len == 0) {
loc_name = (char *)intl_locale_get_default();
Expand Down Expand Up @@ -1318,7 +1318,7 @@ U_CFUNC PHP_FUNCTION(locale_filter_matches)

if( token && (token==cur_lang_tag) ){
/* check if the char. after match is SEPARATOR */
chrcheck = token + (strlen(cur_loc_range));
chrcheck = token + can_loc_range->len;
if( isIDSeparator(*chrcheck) || isKeywordSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
efree( cur_lang_tag );
efree( cur_loc_range );
Expand Down Expand Up @@ -1350,14 +1350,14 @@ U_CFUNC PHP_FUNCTION(locale_filter_matches)
} /* end of if isCanonical */
else{
/* Convert to lower case for case-insensitive comparison */
cur_lang_tag = reinterpret_cast<char *>(ecalloc( 1, strlen(lang_tag ) + 1));
cur_lang_tag = reinterpret_cast<char *>(ecalloc(1, lang_tag_len + 1));

result = strToMatch( lang_tag , cur_lang_tag);
if( result == 0) {
efree( cur_lang_tag );
RETURN_FALSE;
}
cur_loc_range = reinterpret_cast<char *>(ecalloc( 1, strlen(loc_range ) + 1));
cur_loc_range = reinterpret_cast<char *>(ecalloc(1, loc_range_len + 1));
result = strToMatch( loc_range , cur_loc_range );
if( result == 0) {
efree( cur_lang_tag );
Expand All @@ -1370,7 +1370,7 @@ U_CFUNC PHP_FUNCTION(locale_filter_matches)

if( token && (token==cur_lang_tag) ){
/* check if the char. after match is SEPARATOR */
chrcheck = token + (strlen(cur_loc_range));
chrcheck = token + loc_range_len;
if( isIDSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){
efree( cur_lang_tag );
efree( cur_loc_range );
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/msgformat/msgformat_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ U_CFUNC void umsg_parse_helper(UMessageFormat *fmt, int *count, zval **args, UCh

case Formattable::kInt64:
aInt64 = fargs[i].getInt64();
if(aInt64 > ZEND_LONG_MAX || aInt64 < -ZEND_LONG_MAX) {
if(aInt64 > ZEND_LONG_MAX || aInt64 < ZEND_LONG_MIN) {
ZVAL_DOUBLE(&(*args)[i], (double)aInt64);
} else {
ZVAL_LONG(&(*args)[i], (zend_long)aInt64);
Expand Down
25 changes: 25 additions & 0 deletions ext/intl/tests/listformatter/listformatter_get_error.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
IntlListFormatter getErrorCode()/getErrorMessage() reflect format() failures
--EXTENSIONS--
intl
--FILE--
<?php

$formatter = new IntlListFormatter('en_US');

var_dump($formatter->format(["\x80"]));
var_dump($formatter->getErrorCode() === U_INVALID_CHAR_FOUND);
var_dump($formatter->getErrorMessage());

var_dump($formatter->format(['a', 'b']));
var_dump($formatter->getErrorCode() === U_ZERO_ERROR);
var_dump($formatter->getErrorMessage());

?>
--EXPECT--
bool(false)
bool(true)
string(85) "IntlListFormatter::format(): Failed to convert string to UTF-16: U_INVALID_CHAR_FOUND"
string(7) "a and b"
bool(true)
string(12) "U_ZERO_ERROR"
26 changes: 26 additions & 0 deletions ext/intl/tests/msgfmt_parse_int64_min_64.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
MessageFormatter::parse() with PHP_INT_MIN on 64-bit platform
--EXTENSIONS--
intl
--SKIPIF--
<?php if (PHP_INT_SIZE != 8) die("skip 64-bit only"); ?>
--FILE--
<?php

$fmt = new MessageFormatter('en_US', '{0,number,integer}');
$parsed = $fmt->parse('-9,223,372,036,854,775,808');
var_dump($parsed);

$parsed = MessageFormatter::parseMessage('en_US', '{0,number,integer}', '-9,223,372,036,854,775,808');
var_dump($parsed);

?>
--EXPECT--
array(1) {
[0]=>
int(-9223372036854775808)
}
array(1) {
[0]=>
int(-9223372036854775808)
}
Loading