W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2011

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

From: Joshua Bell <josh@lindenlab.com>
Date: Fri, 7 Jan 2011 10:17:26 -0800
Message-ID: <AANLkTinsuaVvWq+41p-V5Vq_D5tfkXYNu-b7DRFJbvp6@mail.gmail.com>
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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:29 UTC