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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>175568</bug_id>
          
          <creation_ts>2017-08-15 03:50:37 -0700</creation_ts>
          <short_desc>data: URL base64 handling different from atob()</short_desc>
          <delta_ts>2023-09-13 13:09:19 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=148128</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=261524</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>255442</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Anne van Kesteren">annevk</reporter>
          <assigned_to name="Anne van Kesteren">annevk</assigned_to>
          <cc>achristensen</cc>
    
    <cc>ap</cc>
    
    <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>dbates</cc>
    
    <cc>d</cc>
    
    <cc>koivisto</cc>
    
    <cc>mathias</cc>
    
    <cc>rbuis</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1338653</commentid>
    <comment_count>0</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2017-08-15 03:50:37 -0700</bug_when>
    <thetext>Tests: https://github.com/w3c/web-platform-tests/pull/6890

Eventual standard: https://github.com/whatwg/fetch/pull/579

It seems better if data: URLs and atob() are aligned.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1338842</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2017-08-15 13:33:19 -0700</bug_when>
    <thetext>Maybe, but don&apos;t they explicitly implement different specs (base64 vs. base64url)?

See also https://github.com/whatwg/html/issues/351</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1339092</commentid>
    <comment_count>2</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2017-08-16 00:05:04 -0700</bug_when>
    <thetext>They don&apos;t, but it does seem like that&apos;s how Safari implements data: URLs, contrary to other browsers.

That&apos;s why data:;base64,___ decodes in Safari and not in Chrome and Firefox.

I&apos;m surprised this hasn&apos;t caused you more compatibility issues. I&apos;ll make sure to add some additional tests for this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1339313</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2017-08-16 15:17:23 -0700</bug_when>
    <thetext>Looking at DataURLDecoder, I see the following logic:
    // First try base64url.
    if (!base64URLDecode(task.encodedData.toStringWithoutCopying(), buffer)) {
        // Didn&apos;t work, try unescaping and decoding as base64.
        auto unescapedString = decodeURLEscapeSequences(task.encodedData.toStringWithoutCopying());
        if (!base64Decode(unescapedString, buffer, Base64IgnoreSpacesAndNewLines))
            return;
    }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1339316</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2017-08-16 15:23:56 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #3)
&gt; Looking at DataURLDecoder, I see the following logic:
&gt;     // First try base64url.
&gt;     if (!base64URLDecode(task.encodedData.toStringWithoutCopying(), buffer))
&gt; {
&gt;         // Didn&apos;t work, try unescaping and decoding as base64.
&gt;         auto unescapedString =
&gt; decodeURLEscapeSequences(task.encodedData.toStringWithoutCopying());
&gt;         if (!base64Decode(unescapedString, buffer,
&gt; Base64IgnoreSpacesAndNewLines))
&gt;             return;
&gt;     }

This was introduced in Bug 148128 when WebKit started doing data URL decoding by itself. Before this, I believe we let CFNetwork decode those for us (No idea exactly how this behaved).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1339423</commentid>
    <comment_count>5</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2017-08-16 21:33:43 -0700</bug_when>
    <thetext>It is there to match the earlier CFNetwork behavior. I believe some tests fail if you remove it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1948457</commentid>
    <comment_count>6</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-04-13 00:24:54 -0700</bug_when>
    <thetext>Rob fixed the tests in https://github.com/WebKit/WebKit/commit/7b467a9d964d4214cfa29005135d429279af7d00 it seems, but I don&apos;t get the impression the code is shared.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1948458</commentid>
    <comment_count>7</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-04-13 00:34:00 -0700</bug_when>
    <thetext>Okay, this in WebLoaderStrategy.cpp seems bad:

    auto mode = DataURLDecoder::Mode::Legacy;
    if (request.requester() == ResourceRequestRequester::Fetch)
        mode = DataURLDecoder::Mode::ForgivingBase64;

Removing DataURLDecoder::Mode::Legacy completely and seeing what breaks seems like a logical next step here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1948459</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-04-13 01:01:07 -0700</bug_when>
    <thetext>&lt;rdar://problem/107982669&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1948460</commentid>
    <comment_count>9</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-04-13 01:02:57 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/12693</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1948825</commentid>
    <comment_count>10</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-04-14 10:54:18 -0700</bug_when>
    <thetext>Committed 262976@main (2518c514c679): &lt;https://commits.webkit.org/262976@main&gt;

Reviewed commits have been landed. Closing PR #12693 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>