StableLib / stablelib

A stable library of useful TypeScript/JavaScript code
https://www.stablelib.com
Other
173 stars 35 forks source link

[base64] Accept whitespaces #55

Open dtinth opened 2 years ago

dtinth commented 2 years ago

Most base-64 decoding libraries accept (and ignore) whitespaces, however this library throws an error.

It would be much more convenient if this library is more lenient in reading base64 data by skipping whitespace characters.

dchest commented 2 years ago

I'm a strong believer in strict encoding/decoding. If the intention is to decode data with whitespaces, it should be explicitly handled by the user by removing them. Especially since this library attempts to be constant-time, unlike others. So I will not enable this by default.

However, there could be a specific decoder, similar to URLSafeCoder, which will skip whitespaces on decoding, and even maybe format on encoding (like openssl base64).