[php-src] master: Revert "ext/intl: Fix NumberFormatter parse offset overflow"

Weilin Du <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Weilin Du (LamentXU123)
Date: 2026-07-03T18:16:32+08:00

Commit: https://github.com/php/php-src/commit/cd7222dbccc0a604467ff877fe5c58c9db002312
Raw diff: https://github.com/php/php-src/commit/cd7222dbccc0a604467ff877fe5c58c9db002312.diff

Revert "ext/intl: Fix NumberFormatter parse offset overflow"

This reverts commit 14a7eadfb25508af19ea831e51e66dc32a7b871e.

Changed paths:
  D  ext/intl/tests/formatter_parse_offset_overflow.phpt
  M  ext/intl/formatter/formatter_parse.cpp


Diff:

diff --git a/ext/intl/formatter/formatter_parse.cpp b/ext/intl/formatter/formatter_parse.cpp
index 7aa92488704a..a475960809b8 100644
--- a/ext/intl/formatter/formatter_parse.cpp
+++ b/ext/intl/formatter/formatter_parse.cpp
@@ -50,12 +50,7 @@ U_CFUNC PHP_FUNCTION( numfmt_parse )
 	}
 
 	if (zposition) {
-		zend_long long_position = zval_get_long(zposition);
-		if (ZEND_LONG_EXCEEDS_INT(long_position)) {
-			zend_argument_value_error(hasThis() ? 3 : 4, "must be between %d and %d", INT32_MIN, INT32_MAX);
-			RETURN_THROWS();
-		}
-		position = (int32_t) long_position;
+		position = (int32_t) zval_get_long(zposition);
 	}
 
 	/* Fetch the object. */
@@ -160,13 +155,8 @@ U_CFUNC PHP_FUNCTION( numfmt_parse_currency )
 	intl_stringFromChar(ustr, str, str_len, &INTL_DATA_ERROR_CODE(nfo));
 	INTL_METHOD_CHECK_STATUS( nfo, "String conversion to UTF-16 failed" );
 
-	if (zposition) {
-		zend_long long_position = zval_get_long(zposition);
-		if (ZEND_LONG_EXCEEDS_INT(long_position)) {
-			zend_argument_value_error(hasThis() ? 3 : 4, "must be between %d and %d", INT32_MIN, INT32_MAX);
-			RETURN_THROWS();
-		}
-		position = (int32_t) long_position;
+	if(zposition) {
+		position = (int32_t) zval_get_long(zposition);
 	}
 
 	icu::ParsePosition pp(position);
diff --git a/ext/intl/tests/formatter_parse_offset_overflow.phpt b/ext/intl/tests/formatter_parse_offset_overflow.phpt
deleted file mode 100644
index 9421c8897511..000000000000
--- a/ext/intl/tests/formatter_parse_offset_overflow.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-NumberFormatter parse offset overflow
---EXTENSIONS--
-intl
---SKIPIF--
-<?php if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
---FILE--
-<?php
-$fmt = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
-$currencyFmt = new NumberFormatter('en_US', NumberFormatter::CURRENCY);
-
-function print_error(callable $callback): void {
-    try {
-        $callback();
-    } catch (Throwable $e) {
-        echo $e::class, ': ', $e->getMessage(), PHP_EOL;
-    }
-}
-
-$offset = PHP_INT_MAX;
-print_error(function () use ($fmt, &$offset) {
-    $fmt->parse('123', NumberFormatter::TYPE_DOUBLE, $offset);
-});
-
-$offset = PHP_INT_MAX;
-print_error(function () use ($fmt, &$offset) {
-    numfmt_parse($fmt, '123', NumberFormatter::TYPE_DOUBLE, $offset);
-});
-
-$currency = '';
-$offset = PHP_INT_MAX;
-print_error(function () use ($currencyFmt, &$currency, &$offset) {
-    $currencyFmt->parseCurrency('$123.00', $currency, $offset);
-});
-
-$currency = '';
-$offset = PHP_INT_MAX;
-print_error(function () use ($currencyFmt, &$currency, &$offset) {
-    numfmt_parse_currency($currencyFmt, '$123.00', $currency, $offset);
-});
-?>
---EXPECT--
-ValueError: NumberFormatter::parse(): Argument #3 ($offset) must be between -2147483648 and 2147483647
-ValueError: numfmt_parse(): Argument #4 ($offset) must be between -2147483648 and 2147483647
-ValueError: NumberFormatter::parseCurrency(): Argument #3 ($offset) must be between -2147483648 and 2147483647
-ValueError: numfmt_parse_currency(): Argument #4 ($offset) must be between -2147483648 and 2147483647
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.