<?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>235308</bug_id>
          
          <creation_ts>2022-01-17 17:50:26 -0800</creation_ts>
          <short_desc>The encoding argument to PAL::decodeURLEscapeSequencesAsData is unnecessary</short_desc>
          <delta_ts>2024-01-02 08:53:56 -0800</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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Andreu Botella">abotella</reporter>
          <assigned_to name="Anne van Kesteren">annevk</assigned_to>
          <cc>achristensen</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1831603</commentid>
    <comment_count>0</comment_count>
    <who name="Andreu Botella">abotella</who>
    <bug_when>2022-01-17 17:50:26 -0800</bug_when>
    <thetext>While investigating bug 235307, I noticed that `PAL::decodeURLEscapeSequencesAsData` only seems to be used in `WebCore::DataURLDecoder`, and the `TextEncoding` object that is passed corresponds to the charset parsed from the data URL&apos;s MIME type. That algorithm is used to encode the parts of the input string that aren&apos;t percent escapes. But the spec&apos;s algorithm to process data URLs (https://fetch.spec.whatwg.org/#data-urls), while it parses the MIME type, it does not try to extract the charset, let alone use it for decoding the body.

What seems to be happening is that the input to the data URL processor is a URL object, and that URL is then serialized in step 2 of the processor (in WebKit, this happens in `DecodeTask::process()`). For data URLs, the result of parsing and serializing is always an ASCII string, with non-ASCII characters percent-encoded as UTF-8 (or as the encoding with which the URL was parsed, if they happen to be parsed as part of the query). Therefore, as long as the `string` parameter to `decodeURLEscapeSequencesAsData` is a serialized URL, there are no code points in the input string that would encode differently depending on the passed encoding*, and so the encoding is effectively irrelevant.

Removing this argument would also make the `charset` field of `WebCore::DataURLDecoder::Result` unnecessary.

*. C0 controls are also serialized, so ISO-2022-JP will behave the same as the rest of encodings.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1833575</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-01-24 17:51:15 -0800</bug_when>
    <thetext>&lt;rdar://problem/88000173&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002189</commentid>
    <comment_count>2</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-12-28 23:59:52 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/22264</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002514</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-01-02 08:53:54 -0800</bug_when>
    <thetext>Committed 272569@main (7e4ae6913e3e): &lt;https://commits.webkit.org/272569@main&gt;

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

    </bug>

</bugzilla>