Skip to content

Fix string encoding of bytes below 0x10 - #31

Merged
sc0Vu merged 1 commit into
web3p:masterfrom
sc0Vuai:fix/str-encode-byte-padding
Sep 23, 2026
Merged

sc0Vu merged 1 commit into
web3p:masterfrom
sc0Vuai:fix/str-encode-byte-padding

Conversation

@sc0Vuai

@sc0Vuai sc0Vuai commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

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)

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

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.11%. Comparing base (0f283fd) to head (fce0ea8).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sc0Vu
sc0Vu merged commit 9d6e61b into web3p:master Sep 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants