[php-src] master: Merge branch 'PHP-8.6'

From: Date: Fri, 02 Oct 2026 16:18:18 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141886@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Date: 2026-10-03T00:14:33+08:00 Commit: https://github.com/php/php-src/commit/82b8dce8b70260276669746edaa3f02bd92e8a50 Raw diff: https://github.com/php/php-src/commit/82b8dce8b70260276669746edaa3f02bd92e8a50.diff Merge branch 'PHP-8.6' * PHP-8.6: ext/intl: Fix overlapping grapheme matches with negative search offsets (#24028) Changed paths: A ext/intl/tests/grapheme_strrpos_negative_offset_overlap.phpt M ext/intl/grapheme/grapheme_util.cpp Diff: diff --git a/ext/intl/grapheme/grapheme_util.cpp b/ext/intl/grapheme/grapheme_util.cpp index 9644df7f3591..33ebde254589 100644 --- a/ext/intl/grapheme/grapheme_util.cpp +++ b/ext/intl/grapheme/grapheme_util.cpp @@ -192,6 +192,12 @@ U_CFUNC int32_t grapheme_strpos_utf16(char *haystack, size_t haystack_len, char break; } prev_pos = char_pos; + int32_t next_pos = ubrk_following(bi, char_pos); + if (next_pos == UBRK_DONE) { + break; + } + usearch_setOffset(src, next_pos, &status); + STRPOS_CHECK_STATUS(status, "Invalid search offset"); } while(1); } } else { diff --git a/ext/intl/tests/grapheme_strrpos_negative_offset_overlap.phpt b/ext/intl/tests/grapheme_strrpos_negative_offset_overlap.phpt new file mode 100644 index 000000000000..aa7fb349ba4d --- /dev/null +++ b/ext/intl/tests/grapheme_strrpos_negative_offset_overlap.phpt @@ -0,0 +1,32 @@ +--TEST-- +grapheme_strrpos() and grapheme_strripos() find overlapping matches with negative offsets +--EXTENSIONS-- +intl +--FILE-- +<?php +foreach (['a', "\u{00E9}", "e\u{0301}", "\u{1F600}"] as $grapheme) { + foreach (['grapheme_strrpos', 'grapheme_strripos'] as $function) { + $positions = []; + foreach ([0, 1, -1, -2, -3] as $offset) { + $positions[] = $function(str_repeat($grapheme, 3), str_repeat($grapheme, 2), $offset); + } + echo $function, ': ', implode(', ', $positions), "\n"; + } +} + +var_dump(grapheme_strripos("\u{00C9}\u{00E9}\u{00C9}", "\u{00E9}\u{00E9}", -1)); +var_dump(grapheme_strrpos("\u{00E9}\u{00E9}x\u{00E9}\u{00E9}", "\u{00E9}\u{00E9}", -1)); +var_dump(grapheme_strrpos("\u{00E9}\u{00E9}x\u{00E9}\u{00E9}", "\u{00E9}\u{00E9}", -3)); +?> +--EXPECT-- +grapheme_strrpos: 1, 1, 1, 1, 0 +grapheme_strripos: 1, 1, 1, 1, 0 +grapheme_strrpos: 1, 1, 1, 1, 0 +grapheme_strripos: 1, 1, 1, 1, 0 +grapheme_strrpos: 1, 1, 1, 1, 0 +grapheme_strripos: 1, 1, 1, 1, 0 +grapheme_strrpos: 1, 1, 1, 1, 0 +grapheme_strripos: 1, 1, 1, 1, 0 +int(1) +int(3) +int(0)

« previous php.cvs (#141886) next »