Skip to content

Fix base encoding edge cases - #13

Merged
baixiangcpp merged 1 commit into
mainfrom
fix-base-encoding-edge-cases
Jun 19, 2026
Merged

Fix base encoding edge cases#13
baixiangcpp merged 1 commit into
mainfrom
fix-base-encoding-edge-cases

Conversation

@baixiangcpp

Copy link
Copy Markdown
Owner

Summary

  • fix Base58 all-zero byte encoding/decoding so leading zero bytes round trip without an extra zero
  • tighten Base32 decode validation for impossible lengths, malformed padding, and non-zero trailing bits
  • add regression tests for the audited edge cases

TDD evidence

  • New tests failed first against the existing implementation:
    • encodeBytesToBase58([0]) returned "11" instead of "1"
    • malformed Base32 inputs such as "A", "AAA", "MZ======", and "MZXW6YTBOI=" were accepted

Verification

  • npm test -- tests/unit/base-encoding-utils.test.ts
  • npm test -- tests/unit/base-encoding-utils.test.ts tests/unit/yaml-json-converter-utils.test.ts
  • npm run lint
  • npm run validate
  • npm test
  • git diff --check

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying byteflow with  Cloudflare Pages  Cloudflare Pages

Latest commit: a34fe89
Status: ✅  Deploy successful!
Preview URL: https://ab6f8c44.byteflow-c58.pages.dev
Branch Preview URL: https://fix-base-encoding-edge-cases.byteflow-c58.pages.dev

View logs

@baixiangcpp
baixiangcpp merged commit 8b8ce54 into main Jun 19, 2026
2 checks passed
@baixiangcpp
baixiangcpp deleted the fix-base-encoding-edge-cases branch June 19, 2026 11:55
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.

1 participant