Commit 33ad78c6ec0 for php

commit 33ad78c6ec00cc8ac1ef1737d1e2c0d71e90377e
Author: Jorg Sowa <jorg.sowa@gmail.com>
Date:   Sat Nov 28 19:39:17 2026 +0100

    ext/mbstring: Re-designate JIS X 0213 plane on switch in ISO-2022-JP-2004 (GH-25871)

    Plane 1 and plane 2 shared the same status value, so switching between
    them omitted the ESC $ ( Q / ESC $ ( P designation and the following
    characters decoded as the wrong plane.

    Closes GH-25871

diff --git a/NEWS b/NEWS
index 92f81843e98..1f6c3bfa1e6 100644
--- a/NEWS
+++ b/NEWS
@@ -129,6 +129,8 @@ PHP                                                                        NEWS
     deeply nested arrays. (Eyüp Can Akman)
   . Fixed the JIT freeing the string returned by mb_encode_mimeheader() or
     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)

 - 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 1c158a852c3..2fad3a1d93e 100644
--- a/ext/mbstring/libmbfl/filters/mbfilter_cjk.c
+++ b/ext/mbstring/libmbfl/filters/mbfilter_cjk.c
@@ -2031,13 +2031,13 @@ static int mbfl_filt_conv_wchar_jis2004(int c, mbfl_convert_filter *filter)
 					s1 |= 0x80;
 					CK((*filter->output_function)(0x8f, filter->data));
 				} else {
-					if ((filter->status & 0xff00) != 0x200) {
+					if ((filter->status & 0xff00) != 0x300) {
 						CK((*filter->output_function)(0x1b, filter->data)); /* ESC */
 						CK((*filter->output_function)('$', filter->data));
 						CK((*filter->output_function)('(', filter->data));
 						CK((*filter->output_function)('P', filter->data));
 					}
-					filter->status = 0x200;
+					filter->status = 0x300;
 				}
 			}

diff --git a/ext/mbstring/tests/mb_strcut_iso2022jp2004_plane_switch.phpt b/ext/mbstring/tests/mb_strcut_iso2022jp2004_plane_switch.phpt
new file mode 100644
index 00000000000..5ceb3e0eafe
--- /dev/null
+++ b/ext/mbstring/tests/mb_strcut_iso2022jp2004_plane_switch.phpt
@@ -0,0 +1,16 @@
+--TEST--
+mb_strcut() re-designates JIS X 0213 plane when switching between planes 1 and 2 in ISO-2022-JP-2004
+--EXTENSIONS--
+mbstring
+--FILE--
+<?php
+foreach (["\u{4FF1}\u{20089}", "\u{20089}\u{4FF1}", "\u{20089}\u{301}"] as $u) {
+	$s = mb_convert_encoding($u, 'ISO-2022-JP-2004', 'UTF-8');
+	$cut = mb_strcut($s, 0, strlen($s), 'ISO-2022-JP-2004');
+	echo bin2hex($cut), ' ', var_export($cut === $s, true), ' ', bin2hex(mb_convert_encoding($cut, 'UTF-8', 'ISO-2022-JP-2004')), "\n";
+}
+?>
+--EXPECT--
+1b2428512e211b24285021211b2842 true e4bfb1f0a08289
+1b24285021211b2428512e211b2842 true f0a08289e4bfb1
+1b24285021211b2428512b5a1b2842 true f0a08289cc81