Skip to content

mruby-regexp: test the F4 upper bound of the four-byte UTF-8 range - #7072

Merged
matz merged 1 commit into
mruby:masterfrom
takumin:regexp-utf8-f4-boundary-test
Aug 10, 2026
Merged

mruby-regexp: test the F4 upper bound of the four-byte UTF-8 range#7072
matz merged 1 commit into
mruby:masterfrom
takumin:regexp-utf8-f4-boundary-test

Conversation

@takumin

@takumin takumin commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #7068.

mrb_re_utf8_charlen() rejects a four-byte sequence that spells a codepoint past U+10FFFF by narrowing the first continuation byte to 0x80 through 0x8f when the lead byte is F4. Nothing exercised that narrowing. The nearest existing case, "\xF5\x80\x80\x80", carries a lead byte outside the four-byte range entirely, so it returns before any continuation byte is looked at.

Add "\xF4\x90\x80\x80", the shortest spelling of U+110000. It takes the F4 branch and scans as four separate bytes.

Test only, no behavior change.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected invalid UTF-8 handling so the sequence F4 90 80 80 is processed as four separate bytes rather than a single character.

`mrb_re_utf8_charlen()` rejects a four-byte sequence that spells a codepoint
past U+10FFFF by narrowing the first continuation byte to `0x80` through `0x8f`
when the lead byte is `F4`. Nothing exercised that narrowing. The nearest
existing case, `"\xF5\x80\x80\x80"`, carries a lead byte outside the four-byte
range entirely, so it returns before any continuation byte is looked at.

Add `"\xF4\x90\x80\x80"`, the shortest spelling of U+110000. It takes the `F4`
branch and scans as four separate bytes.
@takumin
takumin requested a review from matz as a code owner August 10, 2026 11:06
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 077e3f39-2e84-470d-bd36-c861cc569521

📥 Commits

Reviewing files that changed from the base of the PR and between 3cc8975 and 233ef59.

📒 Files selected for processing (1)
  • mrbgems/mruby-regexp/test/regexp.rb

📝 Walkthrough

Walkthrough

The regexp test suite adds a regression assertion for the invalid UTF-8 sequence F4 90 80 80. The assertion verifies that scanning returns four separate bytes.

Changes

Regexp UTF-8 regression

Layer / File(s) Summary
Invalid UTF-8 scan assertion
mrbgems/mruby-regexp/test/regexp.rb
The test verifies that the out-of-range UTF-8 sequence F4 90 80 80 is split into four scan matches.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Suggested reviewers: matz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the regression test for the upper bound of four-byte UTF-8 sequences.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@matz
matz merged commit 0db635c into mruby:master Aug 10, 2026
21 checks passed
@takumin
takumin deleted the regexp-utf8-f4-boundary-test branch August 10, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants