[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Weilin Du | Date: | Wed, 30 Sep 2026 16:33:34 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141806@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-10-01T00:31:03+08:00
Commit: https://github.com/php/php-src/commit/4b5608bbaef20412a0400c17bf4797f45e377e19
Raw diff: https://github.com/php/php-src/commit/4b5608bbaef20412a0400c17bf4797f45e377e19.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Merge branch 'PHP-8.4' into PHP-8.5
Changed paths:
A ext/intl/tests/grapheme_strstr_supplementary_prefix.phpt
M NEWS
M ext/intl/grapheme/grapheme_util.cpp
Diff:
diff --git a/NEWS b/NEWS
index 62c241d520fc..810a69982a79 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,10 @@ PHP NEWS
. Fixed crashes with FFI callbacks created from __call() trampolines
and array callables whose object is released. (Ilia Alshanetsky)
+- Intl:
+ . Fixed grapheme_strstr() and grapheme_stristr() returning incorrect substrings
+ when supplementary characters precede the match. (Weilin Du)
+
- MySQLnd:
. Fixed field_count not resetting on OK packet. (Kamil Tekiela)
. Fixed memory leak when closing a prepared statement after its connection
diff --git a/ext/intl/grapheme/grapheme_util.cpp b/ext/intl/grapheme/grapheme_util.cpp
index fdd69f08a669..e58510e011ca 100644
--- a/ext/intl/grapheme/grapheme_util.cpp
+++ b/ext/intl/grapheme/grapheme_util.cpp
@@ -198,7 +198,7 @@ U_CFUNC int32_t grapheme_strpos_utf16(char *haystack, size_t haystack_len, char
if(char_pos != USEARCH_DONE && ubrk_isBoundary(bi, char_pos)) {
ret_pos = grapheme_count_graphemes(bi, uhaystack,char_pos);
if(puchar_pos) {
- *puchar_pos = char_pos;
+ *puchar_pos = u_countChar32(uhaystack, char_pos);
}
} else {
ret_pos = -1;
diff --git a/ext/intl/tests/grapheme_strstr_supplementary_prefix.phpt
b/ext/intl/tests/grapheme_strstr_supplementary_prefix.phpt
new file mode 100644
index 000000000000..f9f85880604a
--- /dev/null
+++ b/ext/intl/tests/grapheme_strstr_supplementary_prefix.phpt
@@ -0,0 +1,27 @@
+--TEST--
+grapheme_strstr() and grapheme_stristr() preserve match boundaries after supplementary characters
+--EXTENSIONS--
+intl
+--FILE--
+<?php
+foreach (["\u{1F600}", "\u{1F600}\u{1F600}", "\u{1F600}e\u{0301}"] as
$prefix) {
+ $haystack = $prefix . 'abc';
+ var_dump(grapheme_strstr($haystack, 'a'));
+ var_dump(grapheme_strstr($haystack, 'a', true));
+ var_dump(grapheme_stristr($haystack, 'A'));
+ var_dump(grapheme_stristr($haystack, 'A', true));
+}
+?>
+--EXPECT--
+string(3) "abc"
+string(4) "š"
+string(3) "abc"
+string(4) "š"
+string(3) "abc"
+string(8) "šš"
+string(3) "abc"
+string(8) "šš"
+string(3) "abc"
+string(7) "šeĢ"
+string(3) "abc"
+string(7) "šeĢ"