Commit 08acd920aaf for php

commit 08acd920aaf2c8e2a9b06c9b52da277b2f4e1ee6
Author: Jorg Sowa <jorg.sowa@gmail.com>
Date:   Sun Nov 29 16:09:36 2026 +0100

    ext/mbstring: Fix dropped cached char in ISO-2022-JP-2004 flush (GH-25868)

    The flush compared the whole status to 1, so a pending combining base
    character was lost once the encoder had switched to JIS X 0213 plane 1
    (status 0x201). Also fix an off-by-one in the table bounds check.

    Closes GH-25868

diff --git a/NEWS b/NEWS
index f0f2564d446..ef185000e3e 100644
--- a/NEWS
+++ b/NEWS
@@ -136,6 +136,8 @@ PHP                                                                        NEWS
     mb_output_handler() while it is still in use. (Ilia Alshanetsky)
   . Fixed ISO-2022-JP-2004 output omitting the plane designation when switching
     between JIS X 0213 plane 1 and plane 2. (Jorg Sowa)
+  . Fixed ISO-2022-JP-2004 output dropping a trailing combining base character
+    after switching to JIS X 0213 plane 1. (Jorg Sowa)

 - MySQLi:
   . Fixed bug GH-25779 (mysqli_fetch_object() crashes with JIT when the
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_cjk.c b/ext/mbstring/libmbfl/filters/mbfilter_cjk.c
index 2fad3a1d93e..e9d5144f43b 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_cjk.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_cjk.c
@@ -2058,7 +2058,7 @@ static int mbfl_filt_conv_wchar_jis2004_flush(mbfl_convert_filter *filter)
 	k = filter->cache;
 	filter->cache = 0;

-	if (filter->status == 1 && k >= 0 && k <= jisx0213_u2_tbl_len) {
+	if ((filter->status & 0xf) == 1 && k >= 0 && k < jisx0213_u2_tbl_len) {
 		s1 = jisx0213_u2_fb_tbl[k];

 		if (filter->to->no_encoding == mbfl_no_encoding_sjis2004) {
diff --git a/ext/mbstring/tests/mb_strcut_iso2022jp2004_trailing_combining.phpt b/ext/mbstring/tests/mb_strcut_iso2022jp2004_trailing_combining.phpt
new file mode 100644
index 00000000000..1685b1d1055
--- /dev/null
+++ b/ext/mbstring/tests/mb_strcut_iso2022jp2004_trailing_combining.phpt
@@ -0,0 +1,13 @@
+--TEST--
+mb_strcut() keeps trailing combining base character in ISO-2022-JP-2004 after JIS X 0213 plane 1
+--EXTENSIONS--
+mbstring
+--FILE--
+<?php
+$s = mb_convert_encoding("\u{4FF1}か", 'ISO-2022-JP-2004', 'UTF-8');
+echo bin2hex($s), "\n";
+echo bin2hex(mb_strcut($s, 0, strlen($s), 'ISO-2022-JP-2004')), "\n";
+?>
+--EXPECT--
+1b2428512e21242b1b2842
+1b2428512e21242b1b2842