atob rejects valid Base64 without padding
dleviminzi opened ·
I ran into another issue while using PropelAuth's Cloudflare SDK on celld 0.4.1. `atob()` rejects Base64 strings when the trailing `=` padding is omitted, which causes JOSE to fail when decoding JWT signatures.
For now I'm patching the sdk, but apparently that padding is [optional for `atob()`](https://infra.spec.whatwg.org/#forgiving-base64-decode). Here is a minimal repro:
```js atob("YQ=="); // "a" atob("YQ"); // Should also return "a", but throws InvalidCharacterError ```
Here is a patch with a fix:
[0001-Implement-forgiving-Base64-decoding-for-atob.patch](https://github.com/user-attachments/files/32133749/0001-Implement-forgiving-Base64-decoding-for-atob.patch)
My industrious little bot found a few more edge cases, but I will submit separate issues for those to keep the patches focused.
bartlomiejureferenced 9c2d299dd6ablast month on GitHub
ryreferenced e519694581dclast month on GitHub
ryreferenced 4250d366aceblast month on GitHub
ryreferenced 3127cf8e307elast month on GitHub
ryreferenced 12d5b6333fe5last month on GitHub