Changeset 29086 in webkit


Ignore:
Timestamp:
Jan 2, 2008 9:34:41 AM (16 years ago)
Author:
ap@webkit.org
Message:

Reviewed by Darin.

http://bugs.webkit.org/show_bug.cgi?id=14555
action=mailto + method=get - The generated mailto URI is incorrect and the hvalues are encoded twice

http://bugs.webkit.org/show_bug.cgi?id=14774
Submitted data only includes first input item

Reworked encoding of mailto URLs to match other browsers.
Moved most of related logic from FrameLoader::submitForm() to HTMLFormElement::submit().

Tests: fast/forms/mailto/advanced-get.html

fast/forms/mailto/advanced-put.html
fast/forms/mailto/get-multiple-items-text-plain.html
fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html
fast/forms/mailto/get-multiple-items.html
fast/forms/mailto/get-non-ascii.html
fast/forms/mailto/get-non-ascii-text-plain.html
fast/forms/mailto/get-overwrite-query.html
fast/forms/mailto/post-append-query.html
fast/forms/mailto/post-multiple-items-multipart-form-data.html
fast/forms/mailto/post-multiple-items-text-plain.html
fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html
fast/forms/mailto/post-multiple-items.html

  • html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::submit):
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::submitForm):
Location:
trunk
Files:
27 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r29075 r29086  
     12008-01-02  Alexey Proskuryakov  <ap@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=14555
     6        action=mailto + method=get - The generated mailto URI is incorrect and the hvalues are encoded twice
     7
     8        http://bugs.webkit.org/show_bug.cgi?id=14774
     9        Submitted data only includes first input item
     10
     11        * fast/forms/mailto: Added.
     12        * fast/forms/mailto/advanced-get-expected.txt: Added.
     13        * fast/forms/mailto/advanced-get.html: Added.
     14        * fast/forms/mailto/advanced-put-expected.txt: Added.
     15        * fast/forms/mailto/advanced-put.html: Added.
     16        * fast/forms/mailto/get-multiple-items-expected.txt: Added.
     17        * fast/forms/mailto/get-multiple-items-text-plain-expected.txt: Added.
     18        * fast/forms/mailto/get-multiple-items-text-plain.html: Added.
     19        * fast/forms/mailto/get-multiple-items-x-www-form-urlencoded-expected.txt: Added.
     20        * fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html: Added.
     21        * fast/forms/mailto/get-multiple-items.html: Added.
     22        * fast/forms/mailto/get-non-ascii-expected.txt: Added.
     23        * fast/forms/mailto/get-non-ascii.html: Added.
     24        * fast/forms/mailto/get-non-ascii-text-plain.html: Added.
     25        * fast/forms/mailto/get-non-ascii-text-plain-expected.txt: Added.
     26        * fast/forms/mailto/get-overwrite-query-expected.txt: Added.
     27        * fast/forms/mailto/get-overwrite-query.html: Added.
     28        * fast/forms/mailto/post-append-query-expected.txt: Added.
     29        * fast/forms/mailto/post-append-query.html: Added.
     30        * fast/forms/mailto/post-multiple-items-expected.txt: Added.
     31        * fast/forms/mailto/post-multiple-items-multipart-form-data-expected.txt: Added.
     32        * fast/forms/mailto/post-multiple-items-multipart-form-data.html: Added.
     33        * fast/forms/mailto/post-multiple-items-text-plain-expected.txt: Added.
     34        * fast/forms/mailto/post-multiple-items-text-plain.html: Added.
     35        * fast/forms/mailto/post-multiple-items-x-www-form-urlencoded-expected.txt: Added.
     36        * fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html: Added.
     37        * fast/forms/mailto/post-multiple-items.html: Added.
     38
    1392008-01-01  Darin Adler  <darin@apple.com>
    240
  • trunk/WebCore/ChangeLog

    r29085 r29086  
     12008-01-02  Alexey Proskuryakov  <ap@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        http://bugs.webkit.org/show_bug.cgi?id=14555
     6        action=mailto + method=get - The generated mailto URI is incorrect and the hvalues are encoded twice
     7
     8        http://bugs.webkit.org/show_bug.cgi?id=14774
     9        Submitted data only includes first input item
     10
     11        Reworked encoding of mailto URLs to match other browsers.
     12        Moved most of related logic from FrameLoader::submitForm() to HTMLFormElement::submit().
     13
     14        Tests: fast/forms/mailto/advanced-get.html
     15               fast/forms/mailto/advanced-put.html
     16               fast/forms/mailto/get-multiple-items-text-plain.html
     17               fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html
     18               fast/forms/mailto/get-multiple-items.html
     19               fast/forms/mailto/get-non-ascii.html
     20               fast/forms/mailto/get-non-ascii-text-plain.html
     21               fast/forms/mailto/get-overwrite-query.html
     22               fast/forms/mailto/post-append-query.html
     23               fast/forms/mailto/post-multiple-items-multipart-form-data.html
     24               fast/forms/mailto/post-multiple-items-text-plain.html
     25               fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html
     26               fast/forms/mailto/post-multiple-items.html
     27
     28        * html/HTMLFormElement.cpp:
     29        (WebCore::HTMLFormElement::submit):
     30        * loader/FrameLoader.cpp:
     31        (WebCore::FrameLoader::submitForm):
     32
    1332008-01-02  Mark Rowe  <mrowe@apple.com>
    234
  • trunk/WebCore/html/HTMLFormElement.cpp

    r29053 r29086  
    475475
    476476    if (m_post) {
    477         if (!m_multipart)
    478             frame->loader()->submitForm("POST", m_url, formData(0), m_target, enctype(), String(), event);
    479         else {
     477        bool isMailtoForm = m_url.startsWith("mailto:", false);
     478        if (m_multipart && isMailtoForm) {
     479            setEnctype("application/x-www-form-urlencoded");
     480            m_multipart = false;
     481        }
     482
     483        if (!m_multipart) {
     484            RefPtr<FormData> data = formData(0);
     485            if (isMailtoForm) {
     486                String body = data->flattenToString();
     487                if (equalIgnoringCase(enctype(), "text/plain")) {
     488                    // Convention seems to be to decode, and s/&/\r\n/. Also, spaces are encoded as %20.
     489                    body = KURL::decode_string(body.replace('&', "\r\n").replace('+', ' ').deprecatedString() + "\r\n");
     490                }
     491                data = new FormData((String("body=") + encodeCString(body.latin1())).replace('+', "%20").latin1());
     492            }
     493            frame->loader()->submitForm("POST", m_url, data, m_target, enctype(), String(), event);
     494        } else {
    480495            Vector<char> boundary;
    481496            getUniqueBoundaryString(boundary);
  • trunk/WebCore/loader/FrameLoader.cpp

    r28960 r29086  
    540540
    541541    // Handle mailto: forms
    542     bool mailtoForm = u.protocol() == "mailto";
    543     if (mailtoForm) {
    544         // Append body=
    545         String body;
    546         if (equalIgnoringCase(contentType, "multipart/form-data"))
    547             // FIXME: is this correct? I suspect not, but what site can we test this on?
    548             body = formData->flattenToString();
    549         else if (equalIgnoringCase(contentType, "text/plain"))
    550             // Convention seems to be to decode, and s/&/\n/
    551             body = KURL::decode_string(
    552                 formData->flattenToString().replace('&', '\n')
    553                 .replace('+', ' ').deprecatedString()); // Recode for the URL
    554         else
    555             body = formData->flattenToString();
    556 
     542    bool isMailtoForm = equalIgnoringCase(u.protocol(), "mailto");
     543    if (isMailtoForm && strcmp(action, "GET") != 0) {
     544        // Append body= for POST mailto, replace the whole query string for GET one.
     545        String body = formData->flattenToString();
    557546        String query = u.query();
    558547        if (!query.isEmpty())
    559548            query.append('&');
    560         u.setQuery((query + "body=" + KURL::encode_string(body.deprecatedString())).deprecatedString());
     549        u.setQuery((query + body).deprecatedString());
    561550    }
    562551
    563552    if (strcmp(action, "GET") == 0) {
    564         if (!mailtoForm)
    565             u.setQuery(formData->flattenToString().deprecatedString());
     553        u.setQuery(formData->flattenToString().deprecatedString());
    566554    } else {
    567         frameRequest.resourceRequest().setHTTPBody(formData.get());
     555        if (!isMailtoForm)
     556            frameRequest.resourceRequest().setHTTPBody(formData.get());
    568557        frameRequest.resourceRequest().setHTTPMethod("POST");
    569558
Note: See TracChangeset for help on using the changeset viewer.