mruby-regexp: ask the malformed sequence cases of a byte-indexed subject too - #7116
Merged
Merged
Conversation
…ect too Whether an overlong sequence is the character it spells, whether a lone leader at the end of the subject sends the walk past the string buffer, and whether a truncated leader in a class sends it past the pattern buffer are questions about the bytes rather than about how the subject is indexed. Each is asked through a UTF-8 subject only. The engine reads a byte-indexed subject through a branch of its own: `mrb_re_charlen()` and `mrb_re_decode_char()` take a flag for one and hand back a byte at a time. So the walk that must stay inside the buffer at the end of `"ab\xf0"` is a different walk there, and the decode that must not turn C0 BC into `<` is a different decode. Ask each of them on that side as well, next to the case it answers.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe regexp UTF-8 test suite adds byte-indexed subject coverage for truncated, overlong, surrogate, and out-of-range sequences. The assertions verify boundary-safe matching and byte-wise scanning of invalid UTF-8. ChangesUTF-8 regexp regression coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #7110, which asked for one review of a behaviour change and a
large test rewrite at once. This is the second of four pieces, independent of
the first, and changes no behaviour.
Three cases turn on what a malformed sequence is rather than on how the subject
is indexed:
character it spells
buffer
buffer
Each is asked through a UTF-8 subject only.
Why that is a different question to ask
The engine reads a byte-indexed subject through a branch of its own:
mrb_re_charlen()andmrb_re_decode_char()take a flag for one and hand back abyte at a time. So the walk that must stay inside the buffer at the end of
"ab\xf0"is a different walk there, and the decode that must not turnC0 BCinto
<is a different decode. The last two cases came from fuzzing, so thewalk is worth pinning on both sides.
What this does
Asks each of them on that side as well, next to the case it answers.
Verified
rake teston a full-core build (MRB_UTF8_STRINGthrough mruby-encoding):2249 tests, all green
rake teston the default gembox (noMRB_UTF8_STRING): 2058 tests, allgreen
prek run --all-filespasses, except thatmarkdownlintcould not installlocally (npm engine mismatch); no Markdown is touched here
Summary by CodeRabbit