makepad/libs/base64
Ruben Daniels ebe1cab1b7
fix(base64): handle single '=' padding in base64_decode (#1027)
The decoder only checked for double padding ('==') at input[len-2],
subtracting 1 output byte. Single padding ('=') at input[len-1] was
not handled, leaving 1 extra garbage byte in the decoded output.

This affected 2 out of 3 input lengths (any input where len % 3 == 2),
producing decoded output 1 byte longer than expected.

Fix: check input[len-1] for '=' first (subtract 1 byte), then check
input[len-2] for '=' (subtract another byte for double padding).

Added 7 roundtrip tests covering: no padding (3n bytes), single
padding (3n+2 bytes), double padding (3n+1 bytes), empty input,
lengths 1-20, all 256 byte values, and URL-safe alphabet.

Co-authored-by: prime intellect <prime@prime-intellects-Mac-Studio.local>
2026-04-09 20:05:45 +02:00
..
src fix(base64): handle single '=' padding in base64_decode (#1027) 2026-04-09 20:05:45 +02:00
Cargo.toml 1.0.0 2025-05-15 16:46:16 +02:00