Skip to content

fix(node:buffer): estimate base64 byte length#2276

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-buffer-byte-length-base64-edge
May 28, 2026
Merged

fix(node:buffer): estimate base64 byte length#2276
proggeramlug merged 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/node-compat-buffer-byte-length-base64-edge

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Part of #793.

Summary

  • Match Node's Buffer.byteLength(str, "base64"|"base64url") estimate instead of decoding first.
  • Count UTF-16 code units for string inputs, discount up to two trailing = padding characters, and apply the 3/4 base64 ratio.
  • Keep Buffer.from/base64 decode behavior, invalid-base64 validation, and non-base64 encodings out of scope.

Evidence

  • Baseline exact node-suite/buffer/byte-length/edge-encodings: FAIL, report test-parity/reports/parity_report_20260528_110221.json.
  • Final exact node-suite/buffer/byte-length/edge-encodings: PASS, report test-parity/reports/parity_report_20260528_110601.json.
  • Full node-suite/buffer/byte-length: PASS 6/6, report test-parity/reports/parity_report_20260528_110654.json.
  • Full granular node-suite/buffer: 104 PASS / 11 parity FAIL / 1 compile FAIL, report test-parity/reports/parity_report_20260528_110702.json; byte-length is green, with allocation/concat residuals covered by open PRs fix(node:buffer): reject negative allocation size #2274/fix(node:buffer): honor concat total length #2271.
  • cargo check -p perry-runtime -p perry-stdlib -p perry-codegen: PASS with existing warnings.
  • cargo fmt --check, jq empty test-parity/known_failures.json, and git diff --check: PASS.

DeepWiki note saved locally at reference/deepwiki/nodejs-node-buffer-byte-length-base64-edge-2026-05-28.md (not staged).

Non-goals

  • No Buffer.from base64 decode semantics.
  • No invalid-base64 validation.
  • No hex/ascii/utf16 byteLength changes.
  • No broad buffer inventory cleanup.

@proggeramlug proggeramlug merged commit 7c7177f into PerryTS:main May 28, 2026
11 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