Merged
Conversation
📝 WalkthroughWalkthroughAdds explicit handling and validation for 0xC0 and 0xC2..=0xDF MUTF-8 sequences, updates continuation-byte checks, and extends 0xED surrogate handling to compute code points and emit corresponding 4-byte UTF-8 sequences while adjusting buffer/index management. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@haya_mutf8/src/lib.rs`:
- Around line 139-148: In the 0xC0 match arm that inspects let [sec, ref rest @
..] = bytes[..], add an explicit error branch when sec != 0x80 so the function
returns Err(Error) instead of silently accepting an invalid continuation byte;
update the logic around variables bytes, sec, rest and len in that arm to only
increment len and advance bytes when sec == 0x80, otherwise return Err(Error) to
enforce the MUTF-8 rule for the 0xC0 0x80 sequence.
- Around line 209-222: The 0xC0 match arm is advancing index before writing
which causes the 0xC0 0x80 sequence to be copied; in the match arm handling
MUTF-8 null (symbols: bytes, index, start, w.write, w.write_byte) move the index
+= 2 to after the w.write call so you first write
bytes.get_unchecked(start..index) (which excludes the 0xC0), then increment
index by 2, call w.write_byte(b'\0'), and set start = index; keep the same error
path when sec != 0x80.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@haya_mutf8/src/lib.rs`:
- Around line 225-234: The 0xC2..=0xDF branch currently validates the
continuation byte using `sec as i8 >= -64`; replace that check with the same
bitmask style used elsewhere (e.g., `byte & 0xC0 == 0x80`) to match the
`0xE0..=0xEF` branch for consistent readability — locate the `0xC2..=0xDF` match
arm (uses `sec` from `bytes.get(index + 1)`) and update its validation condition
while keeping the same early `Err(Error)` return and `index += 2` behavior.
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.
Summary by CodeRabbit