[whatwg] Specs for window.atob() and window.btoa()

On Fri, Jan 7, 2011 at 9:27 AM, Aryeh Gregor
<Simetrical+w3c at gmail.com<Simetrical%2Bw3c at gmail.com>
> wrote:

> On Fri, Jan 7, 2011 at 12:01 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
>
>
> > Note that it's not that uncommon to use atob on things that came from
> other
> > base64-producing tools, not just from btoa.  Not sure whether that
> matters
> > here.
>
> I don't think it does.  I don't think any base64 encoding
> implementation is likely to pad input strings' lengths to a multiple
> of six bits using anything other than zero bits.  So it's mostly just
> a matter of specification and testing simplicity.
>

It might not hurt to include an *informative* note in the specification that
some base64-encoding tools and APIs by default inject whitespace into any
base64-encoded data they output; for example, line breaks after 76
characters. Therefore, defensively written programs that use window.aotb
should consider the use of something akin to:

var output = window.atob( input.replace(/\s+/g, "" );

Again, this would be informative only; rejection of input strings containing
whitespace is already implicitly covered by your normative text.

Received on Friday, 7 January 2011 10:17:26 UTC