<?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>20668</bug_id>
          
          <creation_ts>2008-09-05 09:58:18 -0700</creation_ts>
          <short_desc>multipart/form-data does not always include Content-type for submitted files</short_desc>
          <delta_ts>2008-09-08 09:23:53 -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>Forms</component>
          <version>525.x (Safari 3.1)</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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Burt">z3gator</reporter>
          <assigned_to name="Alexey Proskuryakov">ap</assigned_to>
          <cc>ap</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>90277</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Burt">z3gator</who>
    <bug_when>2008-09-05 09:58:18 -0700</bug_when>
    <thetext>This was observed using Safari on Mac OS X 10.4 and Windows XP, and Google Chrome on Windows XP, so it is believed to be common to all platforms.  The fundamental problem is that the Content-type for a file submitted using input type=file is not set if the file type (extension?) is not &quot;recognized&quot; (sorry, but I don&apos;t know what determines exactly when it will be set and when it will not).  For example, submitting an Excel (*.xls) file from a client that does not have Excel installed results in the file data being sent with no Content-type specified.  Other browsers set the Content-type to application/octec-stream in this case, and my interpretation of the spec implies that is the correct behavior.

One serious implication of this flaw is that the Struts2 FileUploadInterceptor expects the Content-type to be set for each uploaded file, and when it is missing, the interceptor emits an error and fails to set any of the parameters that are later expected/used by the Struts2 action class to process the file(s).  The net result is that users using applications built on Struts2 are not able to upload files using webkit-based browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90279</commentid>
    <comment_count>1</comment_count>
    <who name="Tim Burt">z3gator</who>
    <bug_when>2008-09-05 10:06:06 -0700</bug_when>
    <thetext>(In reply to comment #0)
&gt; ... application/octec-stream ...
should read application/octet-stream</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90507</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-09-08 04:53:07 -0700</bug_when>
    <thetext>Are there any examples of such applications on he Web to test with? Would it be possible for you to make a test case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90527</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Burt">z3gator</who>
    <bug_when>2008-09-08 06:46:08 -0700</bug_when>
    <thetext>I&apos;m sorry, but the application I&apos;m working with now is not exposed externally, and I don&apos;t have a framework to test webkit.  I was hoping webkit contained some existing tests for multipart/form-data inputs that could be extended to test this situation (i.e. send a file of &quot;unknown&quot; content-type to confirm that Content-type: application/octet-stream is not sent for that file).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90539</commentid>
    <comment_count>4</comment_count>
      <attachid>23259</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-09-08 07:54:13 -0700</bug_when>
    <thetext>Created attachment 23259
test case (a CGI for Apache)

Unfortunately, I don&apos;t think that we have any infrastructure for testing file uploads yet. I made a custom test, and can confirm the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90542</commentid>
    <comment_count>5</comment_count>
      <attachid>23261</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-09-08 08:03:51 -0700</bug_when>
    <thetext>Created attachment 23261
proposed fix</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90543</commentid>
    <comment_count>6</comment_count>
      <attachid>23261</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2008-09-08 08:29:19 -0700</bug_when>
    <thetext>Comment on attachment 23261
proposed fix

r=me

I wish there was a cleaner idiom for &quot;not empty&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90547</commentid>
    <comment_count>7</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2008-09-08 09:23:53 -0700</bug_when>
    <thetext>Committed in &lt;http://trac.webkit.org/changeset/36269&gt;.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>23259</attachid>
            <date>2008-09-08 07:54:13 -0700</date>
            <delta_ts>2008-09-08 07:54:13 -0700</delta_ts>
            <desc>test case (a CGI for Apache)</desc>
            <filename>20668.cgi</filename>
            <type>text/plain</type>
            <size>402</size>
            <attacher name="Alexey Proskuryakov">ap</attacher>
            
              <data encoding="base64">IyEvdXNyL2Jpbi9wZXJsIC13CgpwcmludCAiQ29udGVudC10eXBlOiB0ZXh0L2h0bWxcblxuIjsg
CgppZiAoJEVOVnsnUkVRVUVTVF9NRVRIT0QnfSBlcSAiUE9TVCIpIHsKICAgIHJlYWQoU1RESU4s
ICRyZXF1ZXN0LCAkRU5WeydDT05URU5UX0xFTkdUSCd9KSB8fCBkaWUgIkNvdWxkIG5vdCBnZXQg
cXVlcnlcbiI7CiAgICBwcmludCAiPHByZT4kcmVxdWVzdDwvcHJlPiI7Cn0gZWxzZSB7CiAgICBw
cmludCA8PEVPRgo8Zm9ybSBhY3Rpb249InBvc3QtZWNoby5jZ2kiIG1ldGhvZD1wb3N0IGVuY3R5
cGU9Im11bHRpcGFydC9mb3JtLWRhdGEiPgo8aW5wdXQgdHlwZT1maWxlIG5hbWU9ZmlsZT4KPGlu
cHV0IHR5cGU9dGV4dCBuYW1lPXRleHQ+CjxpbnB1dCB0eXBlPXN1Ym1pdD4KPC9mb3JtPgpFT0YK
fSAK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>23261</attachid>
            <date>2008-09-08 08:03:51 -0700</date>
            <delta_ts>2008-09-08 08:29:19 -0700</delta_ts>
            <desc>proposed fix</desc>
            <filename>20668r1_patch.txt</filename>
            <type>text/plain</type>
            <size>1832</size>
            <attacher name="Alexey Proskuryakov">ap</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiAzNjI2OCkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTcgQEAKKzIwMDgtMDktMDggIEFsZXhleSBQcm9za3VyeWFrb3YgIDxhcEB3ZWJr
aXQub3JnPgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAg
IGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0yMDY2OAorICAgICAgICBt
dWx0aXBhcnQvZm9ybS1kYXRhIGRvZXMgbm90IGFsd2F5cyBpbmNsdWRlIENvbnRlbnQtdHlwZSBm
b3Igc3VibWl0dGVkIGZpbGVzCisKKyAgICAgICAgQ2Fubm90IGJlIHRlc3RlZCB3aXRoIERSVCBv
ciBtYW51YWwgdGVzdHMuCisKKyAgICAgICAgKiBwbGF0Zm9ybS9NSU1FVHlwZVJlZ2lzdHJ5LmNw
cDoKKyAgICAgICAgKFdlYkNvcmU6OmluaXRpYWxpemVTdXBwb3J0ZWROb25JbWFnZU1pbWVUeXBl
cyk6IEZpeCBzcGFjaW5nLgorICAgICAgICAoV2ViQ29yZTo6TUlNRVR5cGVSZWdpc3RyeTo6Z2V0
TUlNRVR5cGVGb3JQYXRoK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W5nIE1JTUVUeXBlUmVnaXN0cnk6
OmdldE1JTUVUeXBlRm9yUAogICAgIGludCBwb3MgPSBwYXRoLnJldmVyc2VGaW5kKCcuJyk7CiAg
ICAgaWYgKHBvcyA+PSAwKSB7CiAgICAgICAgIFN0cmluZyBleHRlbnNpb24gPSBwYXRoLnN1YnN0
cmluZyhwb3MgKyAxKTsKLSAgICAgICAgcmV0dXJuIGdldE1JTUVUeXBlRm9yRXh0ZW5zaW9uKGV4
dGVuc2lvbik7CisgICAgICAgIFN0cmluZyByZXN1bHQgPSBnZXRNSU1FVHlwZUZvckV4dGVuc2lv
bihleHRlbnNpb24pOworICAgICAgICBpZiAocmVzdWx0Lmxlbmd0aCgpKQorICAgICAgICAgICAg
cmV0dXJuIHJlc3VsdDsKICAgICB9CiAgICAgcmV0dXJuICJhcHBsaWNhdGlvbi9vY3RldC1zdHJl
YW0iOwogfQo=
</data>
<flag name="review"
          id="10358"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>