<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22731</bug_id>
          
          <creation_ts>2013-07-19 07:38:19 +0000</creation_ts>
          <short_desc>Should atob() trim spaces, or not?</short_desc>
          <delta_ts>2014-09-26 22:08:54 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#atob</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Needs Impl Interest</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ap</cc>
    
    <cc>chris</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>w3c</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>90973</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-07-19 07:38:19 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html
Multipage: http://www.whatwg.org/C#atob
Complete: http://www.whatwg.org/c#atob
Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html

Comment:
Based on my testing, step 3 (remove all space characters from input) does not
match the current behavior of WebKit, Blink, Firefox and IE10. Should the
specification be updated to match the behavior of all major browsers?

Posted from: 91.154.118.240
User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90975</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">chris</who>
    <bug_when>2013-07-19 07:42:14 +0000</bug_when>
    <thetext>For e.g. the following throws an InvalidCharacterError on all browsers I could test:
atob(&quot;abcd &quot;);

This case is part of the following test suite and is expected to succeed:
http://www.w3c-test.org/html/tests/submission/AryehGregor/base64.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95266</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-10-23 22:09:30 +0000</bug_when>
    <thetext>Seems like a case where improving the implementations might be in order... unless anyone depends on the exception. It&apos;s common to have white space in base64 data.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95293</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2013-10-24 11:01:25 +0000</bug_when>
    <thetext>Yeah the space stripping was a deliberate change to ease the burden on authors and to not waste memory on creating a new string without the whitespace.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95877</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-11-06 18:21:21 +0000</bug_when>
    <thetext>Breaking on non-alphabet characters is an explicit recommendation of RFC 4648, backed by security considerations (see &lt;http://tools.ietf.org/html/rfc4648#section-12&gt;).

It seems like a bad idea to diverge from authoritative spec and from all implementations at the same time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95879</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-06 19:25:23 +0000</bug_when>
    <thetext>The security issues seem pretty minor, but at the end of the day, it&apos;s up to the implementors whether they want to do this or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95964</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">chris</who>
    <bug_when>2013-11-07 17:37:40 +0000</bug_when>
    <thetext>FYI, this is now implemented in Blink:
https://code.google.com/p/chromium/issues/detail?id=314682</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95966</commentid>
    <comment_count>7</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-11-07 17:53:41 +0000</bug_when>
    <thetext>&gt; at the end of the day, it&apos;s up to the implementors whether they want to do this or not.

This doesn&apos;t really add up. Can&apos;t exactly the same be said of every spec mistake, word for word?

Having 1:1 mapping between original and encoded forms is a really nice trait, adding randomness to the process is strange to say the least.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95994</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-07 22:37:02 +0000</bug_when>
    <thetext>&gt; This doesn&apos;t really add up. Can&apos;t exactly the same be said of every spec
&gt; mistake, word for word?

Yes. At the end of the day, the WHATWG HTML spec is just going to spec whatever browsers end up implementing; my job as editor is just to propose what I think (based on the data and arguments I can find and that people bring up) is the optimal behaviour. I don&apos;t file bugs on browsers to implement what I spec, or apply pressure in the form of patches, test cases, or even, except in rare cases, directed advocacy, because I want implementors to carefully consider the text and independently review it and decide whether it&apos;s sane or not before implementing.

On this particular feature, there&apos;s minor security concerns on the one side (people who compare base64 data before decoding it, I guess? I don&apos;t really understand how we end up with a security problem here), and there&apos;s minor performance wins on the other side (spaces in base64 data are common, and not requiring that scripts strip the spaces is a minor win). The back-compat issues don&apos;t seem major (it&apos;s unlikely that people are relying on this throwing an exception on spaces in a way that they&apos;d act worse if it ignored spaces, as far as I can tell). Thus, on the whole, the current text seems like a win to me. However, I could be wrong, and if implementors think I am then they shouldn&apos;t implement it, and if they don&apos;t, then we&apos;ll move the spec back to what they do implement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96022</commentid>
    <comment_count>9</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-11-08 07:20:35 +0000</bug_when>
    <thetext>Ian, was there any evidence of this being an actual measurable performance improvement on any real life web sites?

We already had interoperability across all browsers, supported by RFC recommendation and security concerns, as minor as those may be. The behavior was conceptually cleaner, we don&apos;t want to be liberal in what we accept unless absolutely necessary.

The bar was quite high, and I do not think that this change came anywhere close to meeting it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96065</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-08 23:51:09 +0000</bug_when>
    <thetext>I don&apos;t have a strong feeling about this. (As far as I recall, this wasn&apos;t even something I originally specced, it was Aryeh&apos;s good work.) As noted in comment 8, for me it&apos;s just a minor performance win vs a minor security risk; I don&apos;t really see this as a particularly important issue one way or the other. If the conclusion from implementors is that this is a mistake, then let&apos;s change it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96643</commentid>
    <comment_count>11</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-11-21 17:21:56 +0000</bug_when>
    <thetext>So, let&apos;s change it back?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96657</commentid>
    <comment_count>12</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2013-11-21 19:58:19 +0000</bug_when>
    <thetext>FWIW: Firefox matches the spec as of Firefox 27 (currently on Aurora); see https://bugzilla.mozilla.org/show_bug.cgi?id=711180</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96659</commentid>
    <comment_count>13</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-11-21 20:14:25 +0000</bug_when>
    <thetext>Let&apos;s fix the spec quickly then, before the change is shipped.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96662</commentid>
    <comment_count>14</comment_count>
    <who name="Chris Dumez">chris</who>
    <bug_when>2013-11-21 20:26:15 +0000</bug_when>
    <thetext>So Firefox and Blink already follow the specification so it looks like there was interest from  browser vendors.

There is also a patch up-for-review to implement this in WebKit so we are actually really close to cross-browser support.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96663</commentid>
    <comment_count>15</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-11-21 20:49:19 +0000</bug_when>
    <thetext>Was there an analysis of these issues performed by Mozilla or Google?

Again, this is a basic feature of Base64 encoding. Generally, it&apos;s a very desirable trait for any encoding that you can&apos;t add undetectable noise to it. Many applications of Base64 (notably JOSE, used in WebCrypto) additionally forbid padding with &apos;=&apos; characters. So for security applications, space and &apos;=&apos; padding is forbidden.

Do we really want to re-evaluate all applications of Base64 just to make this small silly change?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97423</commentid>
    <comment_count>16</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-12-10 22:23:19 +0000</bug_when>
    <thetext>cc&apos;ing abarth who may have an opinion about the security implications, since Chrome does this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100072</commentid>
    <comment_count>17</comment_count>
    <who name="Adam Barth">w3c</who>
    <bug_when>2014-02-07 23:44:14 +0000</bug_when>
    <thetext>I&apos;m not sure I understand what the security issue is supposed to be.  The RFC seems worried about covert channels, which aren&apos;t usually a threat model we worry about in the web platform</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112318</commentid>
    <comment_count>18</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-26 21:26:38 +0000</bug_when>
    <thetext>Given the lay of the land, I think the logical thing to do is to leave the spec as-is instead of changing it to match the Safari behaviour. I understand that this is not something where everyone is on the same page, but I don&apos;t see how else to make progress.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>112325</commentid>
    <comment_count>19</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2014-09-26 22:08:54 +0000</bug_when>
    <thetext>It&apos;s not &quot;Safari behavior&quot;, it&apos;s everyone&apos;s behavior before this essentially unmotivated spec change was made :-/</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>