Bug 111585 - [test-case] KHTML forces METHOD="POST" if enctype="multipart/form-data" is specified
Summary: [test-case] KHTML forces METHOD="POST" if enctype="multipart/form-data" is sp...
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: khtml (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 265082 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-08-26 21:25 UTC by Jeremy Shaw
Modified: 2011-02-06 15:37 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Shaw 2005-08-26 21:25:30 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Debian testing/unstable Packages
OS:                Linux

I think KHTML is doing the wrong thing when a form has method="GET" *AND* enctype="multipart/form-data".

Using method="GET" implies that the enctype MUST be enctype="application/x-www-form-urlencoded".
At the same time, "multipart/form-data" is only sensible for use with POST. So, the html is not really that sensible in the first place, but I still think khtml is doing the wrong thing when it runs across it. (And, unfortunately, a
popular(?) perl CGI library is broken and sets enctype="multipart/form-data" for all forms when outputting xhtml).

If you specify both, khtml currently decides to POST the data as multipart/form-data.

I believe the correct thing to do is to GET the formdata as application/x-www-form-urlencoded.

According to the HTML 4.01 spec, section 17.13.3

http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13.3

 + If the method is "get" and the action is an HTTP URI, the user agent takes the value of action, appends a `?' to it, then appends the form data set, encoded using the "application/x-www-form-urlencoded" content type. The user agent then traverses the link to this URI. In this scenario, form data are restricted to ASCII codes.

 + If the method is "post" and the action is an HTTP URI, the user agent conducts an HTTP "post" transaction using the value of the action attribute and a message created according to the content type specified by the enctype attribute.

Looking at the code, It appears that khtml tries do the right thing:

from kdelibs/khtml/khtml_part.cpp -> KHTMLPart::submitForm():

  if ( strcmp( action, "get" ) == 0 ) {
    if (u.protocol() != "mailto")
       u.setQuery( QString::fromLatin1( formData.data(), formData.size() ) );
    args.setDoPost( false );
  }
  else {
    args.postData = formData;
    args.setDoPost( true );
    <snip>
  }

However, it may be getting messed up in this section of code:
from khtml/html/html_formimpl.cpp -> HTMLFormElementImpl::setEnctype()

    if(type.string().find("multipart", 0, false) != -1 || type.string().find("form-data", 0, false) != -1)
    {
        m_enctype = "multipart/form-data";
        m_multipart = true;
        m_post = true;
    }

It sets m_post to true, regardless of what METHOD is set to. Fixing it appears to be a bit tricky, because setEnctype() needs to know what METHOD is really set to -- but setEnctype() currently has no way of knowing that.
Comment 1 Martin Fitzpatrick 2007-01-09 21:41:00 UTC
Bug confirmed under KDE 3.5.5 / Kubuntu 6.10.

Test case available online at: http://localhost/kde/bug111585.php - simply hit the submit button & the script will return success/failure. Firefox passes this test.
Comment 2 Martin Fitzpatrick 2007-01-09 21:42:23 UTC
Oh dear. Correct url: http://www.mutube.com/x/kde/bug111585.php
Comment 3 Martin Fitzpatrick 2008-04-05 21:57:59 UTC
In 4.0.3 Konqueror passes this test. Can someone confirm for 3.5.9 to close? Thanks.
Comment 4 Linus Östberg 2008-04-19 17:55:46 UTC
Bug is still remaining in 3.5.9.
Comment 5 Maksim Orlovich 2010-06-06 20:46:26 UTC
SVN commit 1135189 by orlovich:

Don't force POST for multipart, rather ignore multipart when not in POST

BUG:111585
BUG:240380


 M  +5 -4      html_formimpl.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1135189
Comment 6 Maksim Orlovich 2011-02-06 15:37:04 UTC
*** Bug 265082 has been marked as a duplicate of this bug. ***