Skip to content

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

Open
jorgsowa wants to merge 1 commit into
php:PHP-8.4from
jorgsowa:fix-jis2004-flush-cached-char
Open

jorgsowa wants to merge 1 commit into
php:PHP-8.4from
jorgsowa:fix-jis2004-flush-cached-char

Conversation

@jorgsowa

Copy link
Copy Markdown
Contributor

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.

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.
@iliaal

iliaal commented Nov 28, 2026

Copy link
Copy Markdown
Member

One sibling the fix doesn't cover: the plane 2 branch of mbfl_filt_conv_wchar_jis2004() also sets status to 0x200, so the legacy encoder can't tell the planes apart and never re-emits ESC $ ( Q. mb_strcut() on "\u{20089}か" in ISO-2022-JP-2004 now keeps the か but emits it as plane 2 0x242B, and "\u{20089}\u{4FF1}" breaks the same way with no combining character involved. A separate status for plane 2 (0x300) would fix both.

@iliaal iliaal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, GH-25871 already covers the plane 2 status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants