Fix string encoding of bytes below 0x10 - #31
Merged
Merged
Conversation
Str::encode converted each byte with dechex(), which drops the leading zero nibble (0x01 -> "1"). Strings containing bytes 0x00-0x0f were encoded with wrong payloads and lengths, e.g. "\x01\x02" -> "12" instead of "820102". Pad each byte to two hex digits in the utf8 and ascii branches. Add regression vectors for low bytes and a 256-byte all-values string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #31 +/- ##
============================================
+ Coverage 74.17% 82.11% +7.94%
Complexity 55 55
============================================
Files 3 3
Lines 151 151
============================================
+ Hits 112 124 +12
+ Misses 39 27 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Str::encode converted each byte with dechex(), which drops the leading zero, so 0x01 became 1. Strings containing bytes 0x00–0x0f were encoded wrongly: "\x01\x02" gave 12 instead of 820102, and "a\nb" gave 83061a62 instead of 83610a62. Each byte is now written as two hex digits in both the utf8 and ascii branches.
Adds regression vectors for low bytes, a string inside a list, and a string of all 256 byte values (encode and decode).
🤖 Generated with Claude Code (https://claude.com/claude-code)