<?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>23566</bug_id>
          
          <creation_ts>2009-01-26 23:48:22 -0800</creation_ts>
          <short_desc>base64Decode() patch</short_desc>
          <delta_ts>2023-05-22 04:08:56 -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>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Paul Pedriana">ppedriana</reporter>
          <assigned_to name="Paul Pedriana">ppedriana</assigned_to>
          <cc>annevk</cc>
    
    <cc>skyul</cc>
    
    <cc>thomas</cc>
    
    <cc>youandmealwaysand4evermylove03</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>107164</commentid>
    <comment_count>0</comment_count>
    <who name="Paul Pedriana">ppedriana</who>
    <bug_when>2009-01-26 23:48:22 -0800</bug_when>
    <thetext>The base64Decode function doesn&apos;t follow the Base64 convention regarding unrecognized encoding characters, as stated in RFC 2045:

    All line breaks or other characters not found in 
    Table 1 must be ignored by decoding software.

Similary, there is corresponding code comments in some WebKit code:

    // Use the GLib Base64 if available, since WebCore&apos;s decoder isn&apos;t
    // general-purpose and fails on Acid3 test 97 (whitespace).

This patch fixes the base64Decode function in this respect.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107165</commentid>
    <comment_count>1</comment_count>
      <attachid>27068</attachid>
    <who name="Paul Pedriana">ppedriana</who>
    <bug_when>2009-01-26 23:50:25 -0800</bug_when>
    <thetext>Created attachment 27068
base64Decode patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107193</commentid>
    <comment_count>2</comment_count>
      <attachid>27068</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-01-27 09:08:43 -0800</bug_when>
    <thetext>Comment on attachment 27068
base64Decode patch

Looks good!

&gt; +2009-01-26  Paul  &lt;set EMAIL_ADDRESS environment variable&gt;

This should have your full name and your email address. Remember that prepare-ChangeLog helps you write a change log, but doesn&apos;t write it for you. You may have to fix things.

&gt; +          Fixed bug whereby base64Decode() was failing when unrecognized encoding chars

You call this a bug in base64Decode, but it&apos;s actually the design of base64Decode. For example, this comment is in the header:

    // this decoder is not general purpose - it returns an error if it encounters a linefeed, as needed for window.atob

Changing this behavior might be helpful for some callers and harmful for others.

&gt; +          were present, whereas the base64 specification requires such chars be ignored.
&gt; +          This allows some base64 tests, such as that in Acid3, to succeed where they previous failed.

I don&apos;t understand this. I believe the Acid3 test already passes. Perhaps you&apos;re talking specifically about something in the curl or soup handling of data URLs? If so, please be specific.

I believe your change may have improved data URLs for those protocols, but incompatibly changed the behavior of window.atob. Please supply some test cases to demonstrate the change in behavior of atob and check the behavior of other browsers, or submit a patch that does not change the behavior of atob.

Also, please be more specific in your comments. I don&apos;t think &quot;some base64 tests, such as that in Acid3&quot; points clearly enough to the curl and soup implementations, if indeed that&apos;s what you&apos;re fixing.

review- because either:

    1) This fixes a bug in atob, but doesn&apos;t include a test case demonstrating that bug.

or

    2) This introduces a bug in atob, so shouldn&apos;t be checked in as-is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107195</commentid>
    <comment_count>3</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-01-27 09:09:32 -0800</bug_when>
    <thetext>This bug needs a title that makes it clear what the problem is. Perhaps &quot;data URL decoding in curl/soup does not skip illegal base64 characters as required by spec&quot;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107220</commentid>
    <comment_count>4</comment_count>
    <who name="Paul Pedriana">ppedriana</who>
    <bug_when>2009-01-27 11:08:27 -0800</bug_when>
    <thetext>I posted this as a followup to this email:
    https://lists.webkit.org/pipermail/webkit-dev/2008-December/006015.html

The original bug is that base-64 data URL data decoding in some cases is incorrect, but it seems to me that the existing WebKit window.atob is also incorrect, now that you point it out. 

Acid3 data URL support might pass for CoreFoundation, but it won&apos;t pass for other back-ends present in the WebKit trunk.

The window.atob function, by definition, decodes base-64 data (e.g. http://docs.sun.com/source/816-6408-10/window.htm#1201548), and so this patch would fix a bug in the existing window.atob implementation. 

However, as you point out, this patch should include a test case exercising the effect on window.atob. Perhaps I can augment it to do this and resubmit. I&apos;m pretty sure the patch would be safe for window.atob, as it simply allows something to work that would previously fail (where it shouldn&apos;t).

Does that seem reasonable, or should the issue of data URLs and window.atob be addressed independently for some reason?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1956913</commentid>
    <comment_count>5</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-05-22 04:08:56 -0700</bug_when>
    <thetext>The code probably changed a fair bit here over the years, but we also don&apos;t want to follow the RFC directly as stated above. The code should be even clearer about this today and it has better test coverage too.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>27068</attachid>
            <date>2009-01-26 23:50:25 -0800</date>
            <delta_ts>2010-06-10 16:33:13 -0700</delta_ts>
            <desc>base64Decode patch</desc>
            <filename>Base64.patch</filename>
            <type>text/plain</type>
            <size>1837</size>
            <attacher name="Paul Pedriana">ppedriana</attacher>
            
              <data encoding="base64">SW5kZXg6IENoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLS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LyA0KTsKKyAgICBpZiAoIW91dExlbiB8fCAoKG91dExlbiArIDIp
IC8gMykgKiA0IDwgb3V0U2l6ZSkKICAgICAgICAgcmV0dXJuIGZhbHNlOwogCiAgICAgdW5zaWdu
ZWQgc2lkeCA9IDA7Cg==
</data>
<flag name="review"
          id="12989"
          type_id="1"
          status="-"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>