<?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>19794</bug_id>
          
          <creation_ts>2008-06-27 11:48:02 -0700</creation_ts>
          <short_desc>[CURL] Crash if a local file has an unknow extension</short_desc>
          <delta_ts>2009-08-17 15:51:35 -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>Page Loading</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Curl</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Marco Barisione">marco.barisione</reporter>
          <assigned_to name="Marco Barisione">marco.barisione</assigned_to>
          <cc>ahya365</cc>
    
    <cc>bfulgham</cc>
    
    <cc>jmalonzo</cc>
    
    <cc>marco.barisione</cc>
    
    <cc>uws+webkit</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>84597</commentid>
    <comment_count>0</comment_count>
    <who name="Marco Barisione">marco.barisione</who>
    <bug_when>2008-06-27 11:48:02 -0700</bug_when>
    <thetext>MIMETypeRegistry::getMIMETypeForPath returns empty strings if the extension is not known. This also causes a crash because of the CURL backend setting the mime type to an empty string if the local file has an unknown extension.

From the code using the function and in particular from the comment in FrameLoaderClient::objectContentType() I think that the right behaviour is that getMIMETypeForPath should return &quot;application/octet-stream&quot; upon failure, while getMIMETypeForExtension should return an empty string.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84599</commentid>
    <comment_count>1</comment_count>
    <who name="Marco Barisione">marco.barisione</who>
    <bug_when>2008-06-27 12:05:15 -0700</bug_when>
    <thetext>Sorry, I realise only now that this is not GTK-specific code and that other ports have the same behaviour without breaking anything.

I still wonder why MIMETypeRegistry::getMIMETypeForPath() returns an empty string if the extension is not known but application/octet-stream if there is no extension, however the right fix is in the CURL code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>84845</commentid>
    <comment_count>2</comment_count>
      <attachid>22023</attachid>
    <who name="Marco Barisione">marco.barisione</who>
    <bug_when>2008-07-01 03:46:59 -0700</bug_when>
    <thetext>Created attachment 22023
Set the MIME type for files with an unknown extension to  &quot;application/octet-stream&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86090</commentid>
    <comment_count>3</comment_count>
    <who name="Wouter Bolsterlee">uws+webkit</who>
    <bug_when>2008-07-16 12:29:03 -0700</bug_when>
    <thetext>&gt; MIMETypeRegistry::getMIMETypeForPath returns
&gt; empty strings if the extension is not known.

Why is that? Why not a null value or something like that?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87652</commentid>
    <comment_count>4</comment_count>
      <attachid>22023</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-08-01 16:57:52 -0700</bug_when>
    <thetext>Comment on attachment 22023
Set the MIME type for files with an unknown extension to  &quot;application/octet-stream&quot;

Why does curl crash when passed an empty string?  The right fix is right next to the line of curl code which is going to crash...  At least an ASSERT should go next to said line.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87937</commentid>
    <comment_count>5</comment_count>
    <who name="Marco Barisione">marco.barisione</who>
    <bug_when>2008-08-06 03:59:12 -0700</bug_when>
    <thetext>I think that we have 3 different problems:

1. RegularExpression::match() should not pass a null string to jsRegExpExecute. I opened a separate bug report for this, see bug #20295.

2. getMIMETypeForPath() returns &quot;application/octet-stream&quot; if there is not extension but getMIMETypeForExtension() returns a null string. If don&apos;t like this difference because it&apos;s confusing, but we have code that relies on that and also the win port has the same behaviour but it doesn&apos;t crash as it doesn&apos;t use the MIMETypeRegistry in this case. I don&apos;t know what the mac port does because it calls a function without public source code. The qt port always defaults to &quot;application/octet-stream&quot; so it&apos;s not affected by this problem. The soup back-end uses a function in gio for this instead of the MIMETypeRegistry, so it&apos;s not affected.
Unless someone (Alp?) thinks that changing getMIMETypeForExtension() to never return a null string is the right behaviour I think that my previous patch is useful, so I&apos;m setting the review flag again

3. For now we don&apos;t have downloads in the GTK ports, so WebKit tries to show also unknown mime types. Of course this is wrong but crashing in this case is wronger :)

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88261</commentid>
    <comment_count>6</comment_count>
      <attachid>22023</attachid>
    <who name="Holger Freyther">zecke</who>
    <bug_when>2008-08-11 18:24:06 -0700</bug_when>
    <thetext>Comment on attachment 22023
Set the MIME type for files with an unknown extension to  &quot;application/octet-stream&quot;

Please patch MIMETypeRegistry::getMIMETypeForExtension (WebCore/platform/gtk/MIMETypeRegistryGtk.cpp) to have it return application/octet-stream by default, this would match with the default return of ::getMIMETypeForPath.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88294</commentid>
    <comment_count>7</comment_count>
    <who name="Marco Barisione">marco.barisione</who>
    <bug_when>2008-08-12 02:12:10 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; (From update of attachment 22023 [edit])
&gt; Please patch MIMETypeRegistry::getMIMETypeForExtension
&gt; (WebCore/platform/gtk/MIMETypeRegistryGtk.cpp) to have it return
&gt; application/octet-stream by default, this would match with the default return
&gt; of ::getMIMETypeForPath.

Are you sure that this is the right behaviour? It&apos;s what I wanted to do at the beginning but then I found code relying on the null return value and also other ports do the same as the GTK one.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92539</commentid>
    <comment_count>8</comment_count>
    <who name="Marco Barisione">marco.barisione</who>
    <bug_when>2008-09-24 09:21:14 -0700</bug_when>
    <thetext>Any new opinion on this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96633</commentid>
    <comment_count>9</comment_count>
    <who name="Jan Alonzo">jmalonzo</who>
    <bug_when>2008-10-24 20:08:47 -0700</bug_when>
    <thetext>(In reply to comment #8)
&gt; Any new opinion on this?
&gt; 

String MIMETypeRegistry::getMIMETypeForPath(const String&amp; path) (platform/MIMETypeRegistry.cpp) already returns &quot;application/octet-stream&quot; if it can&apos;t find a mime type. We need to figure out why it&apos;s returning something else (empty string in this case) and not application/octet-stream. I would&apos;ve been easier if you can provide at least a test url / case for this.

Here&apos;s the code i&apos;m talking about:

String MIMETypeRegistry::getMIMETypeForPath(const String&amp; path)
{
    int pos = path.reverseFind(&apos;.&apos;);
    if (pos &gt;= 0) {
        String extension = path.substring(pos + 1);
        String result = getMIMETypeForExtension(extension);
        if (result.length())
            return result;
    }
    return &quot;application/octet-stream&quot;;
}
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111331</commentid>
    <comment_count>10</comment_count>
    <who name="Gustavo Noronha (kov)">gustavo</who>
    <bug_when>2009-02-26 15:33:31 -0800</bug_when>
    <thetext>Removing the Gtk keyword since Curl is no longer used by the GTK+ port.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>140376</commentid>
    <comment_count>11</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-08-14 16:09:43 -0700</bug_when>
    <thetext>I wonder if this is the same as Bug 28312?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>140854</commentid>
    <comment_count>12</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-08-17 15:51:35 -0700</bug_when>
    <thetext>I believe this is resolved by Bug 28312 for the following reasons:

1.  Full header processing prior to Bug 28312 was not being performed for local files.
2.  If the header processing is not performed, no URL is every set in the request object.
3.  If the URL is not set, the attempt to retrieve MIME type crashes due to null access in the HashMap.

Since there is no specific test case documented in this bug, and my attempts to access local files with meaningless extensions does not generate any failures with current WebKit builds, I am closing this bug as resolved.

If you do continue to see this bug, please provide a simple test case I can use to see what&apos;s going on.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>22023</attachid>
            <date>2008-07-01 03:46:59 -0700</date>
            <delta_ts>2008-08-11 18:24:06 -0700</delta_ts>
            <desc>Set the MIME type for files with an unknown extension to  &quot;application/octet-stream&quot;</desc>
            <filename>curl-unknown-extension.patch</filename>
            <type>text/plain</type>
            <size>1838</size>
            <attacher name="Marco Barisione">marco.barisione</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvcGxhdGZvcm0vbmV0d29yay9jdXJsL1Jlc291cmNlSGFuZGxlTWFuYWdl
ci5jcHAKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PQotLS0gV2ViQ29yZS9wbGF0Zm9ybS9uZXR3b3JrL2N1cmwvUmVzb3Vy
Y2VIYW5kbGVNYW5hZ2VyLmNwcAkocmV2aXNpb25lIDM0OTExKQorKysgV2ViQ29yZS9wbGF0Zm9y
bS9uZXR3b3JrL2N1cmwvUmVzb3VyY2VIYW5kbGVNYW5hZ2VyLmNwcAkoY29waWEgbG9jYWxlKQpA
QCAtMyw2ICszLDcgQEAKICAqIENvcHlyaWdodCAoQykgMjAwNiBNaWNoYWVsIEVtbWVsIG1pa2Uu
ZW1tZWxAZ21haWwuY29tCiAgKiBDb3B5cmlnaHQgKEMpIDIwMDcgQWxwIFRva2VyIDxhbHAudG9r
ZXJAY29sbGFib3JhLmNvLnVrPgogICogQ29weXJpZ2h0IChDKSAyMDA3IEhvbGdlciBIYW5zIFBl
dGVyIEZyZXl0aGVyCisgKiBDb3B5cmlnaHQgKEMpIDIwMDggQ29sbGFib3JhIEx0ZC4KICAqIEFs
bCByaWdodHMgcmVzZXJ2ZWQuCiAgKgogICogUmVkaXN0cmlidXRpb24gYW5kIHVzZSBpbiBzb3Vy
Y2UgYW5kIGJpbmF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gTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgW0NV
UkxdIENyYXNoIGlmIGEgbG9jYWwgZmlsZSBoYXMgYW4gdW5rbm93biBleHRlbnNpb24KKyAgICAg
ICAgaHR0cDovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MTk3OTQKKworICAgICAg
ICBTZXQgdGhlIE1JTUUgdHlwZSBmb3IgZmlsZXMgd2l0aCBhbiB1bmtub3duIGV4dGVuc2lvbiB0
bworICAgICAgICAiYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtIi4KKworICAgICAgICAqIHBsYXRm
b3JtL25ldHdvcmsvY3VybC9SZXNvdXJjZUhhbmRsZU1hbmFnZXIuY3BwOgorICAgICAgICAoV2Vi
Q29yZTo6UmVzb3VyY2VIYW5kbGVNYW5hZ2VyOjppbml0aWFsaXplSGFuZGxlKToKKwogMjAwOC0w
Ny0wMSAgQWxwIFRva2VyICA8YWxwQG51YW50aS5jb20+CiAKICAgICAgICAgUnViYmVyLXN0YW1w
ZWQgYnkgSG9sZ2VyLgo=
</data>
<flag name="review"
          id="9690"
          type_id="1"
          status="-"
          setter="zecke"
    />
          </attachment>
      

    </bug>

</bugzilla>