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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29086
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-01-02 Alexey Proskuryakov <ap@webkit.org>
+
+ 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
+
+ * fast/forms/mailto: Added.
+ * fast/forms/mailto/advanced-get-expected.txt: Added.
+ * fast/forms/mailto/advanced-get.html: Added.
+ * fast/forms/mailto/advanced-put-expected.txt: Added.
+ * fast/forms/mailto/advanced-put.html: Added.
+ * fast/forms/mailto/get-multiple-items-expected.txt: Added.
+ * fast/forms/mailto/get-multiple-items-text-plain-expected.txt: Added.
+ * fast/forms/mailto/get-multiple-items-text-plain.html: Added.
+ * fast/forms/mailto/get-multiple-items-x-www-form-urlencoded-expected.txt: Added.
+ * fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html: Added.
+ * fast/forms/mailto/get-multiple-items.html: Added.
+ * fast/forms/mailto/get-non-ascii-expected.txt: Added.
+ * fast/forms/mailto/get-non-ascii.html: Added.
+ * fast/forms/mailto/get-non-ascii-text-plain.html: Added.
+ * fast/forms/mailto/get-non-ascii-text-plain-expected.txt: Added.
+ * fast/forms/mailto/get-overwrite-query-expected.txt: Added.
+ * fast/forms/mailto/get-overwrite-query.html: Added.
+ * fast/forms/mailto/post-append-query-expected.txt: Added.
+ * fast/forms/mailto/post-append-query.html: Added.
+ * fast/forms/mailto/post-multiple-items-expected.txt: Added.
+ * fast/forms/mailto/post-multiple-items-multipart-form-data-expected.txt: Added.
+ * fast/forms/mailto/post-multiple-items-multipart-form-data.html: Added.
+ * fast/forms/mailto/post-multiple-items-text-plain-expected.txt: Added.
+ * fast/forms/mailto/post-multiple-items-text-plain.html: Added.
+ * fast/forms/mailto/post-multiple-items-x-www-form-urlencoded-expected.txt: Added.
+ * fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html: Added.
+ * fast/forms/mailto/post-multiple-items.html: Added.
+
2008-01-01 Darin Adler <darin@apple.com>
Reviewed by Eric.
--- /dev/null
+Frame attempted to load mailto:?to=to1%40site.com%2Cto2%40site.com%2Cto3%40site.com&cc=cc1%40site.com%2Ccc2%40site.com%2Ccc3%40site.com&bcc=bcc1%40site.com%2Cbcc2%40site.com%2Cbcc3%40site.com&subject=m%26m%3B%3F%3D&body=line1%0D%0Aline2%0D%0Aline3%0D%0Aline4
+Press Compose button and check that the created e-mail has correct headers and body.
+
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>action="mailto" GET method</title>
+ <script>
+ function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+ }
+ </script>
+ </head>
+ <body onload="test()">
+ <p>Press Compose button and check that the created e-mail has correct headers and body.</p>
+ <form action="mailto:" method="get">
+ <input name="to" value="to1@site.com,to2@site.com,to3@site.com">
+ <input name="cc" value="cc1@site.com,cc2@site.com,cc3@site.com">
+ <input name="bcc" value="bcc1@site.com,bcc2@site.com,bcc3@site.com">
+ <input name="subject" value="m&m;?=">
+<textarea name="body">line1
+line2
+line3
+line4</textarea>
+ <input type="submit" value="Compose">
+ </form>
+ </body>
+</html>
--- /dev/null
+Frame attempted to load mailto:?to=to1%40site.com%2Cto2%40site.com%2Cto3%40site.com&cc=cc1%40site.com%2Ccc2%40site.com%2Ccc3%40site.com&bcc=bcc1%40site.com%2Cbcc2%40site.com%2Cbcc3%40site.com&subject=m%26m%3B%3F%3D&body=line1%0D%0Aline2%0D%0Aline3%0D%0Aline4
+Press Compose button and check that the created e-mail has correct headers and body.
+
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>action="mailto" PUT method</title>
+ <script>
+ function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+ }
+ </script>
+ </head>
+ <body onload="test()">
+ <p>Press Compose button and check that the created e-mail has correct headers and body.</p>
+ <form action="mailto:" method="put">
+ <input name="to" value="to1@site.com,to2@site.com,to3@site.com">
+ <input name="cc" value="cc1@site.com,cc2@site.com,cc3@site.com">
+ <input name="bcc" value="bcc1@site.com,bcc2@site.com,bcc3@site.com">
+ <input name="subject" value="m&m;?=">
+<textarea name="body">line1
+line2
+line3
+line4</textarea>
+ <input type="submit" value="Compose">
+ </form>
+ </body>
+</html>
--- /dev/null
+Frame attempted to load mailto:nobody@gmail.com?field1=value+1&field2=value+2
+Field 1: Field 2:
+Expected results when clicking "Send" button: A new mail message is created with an empty body.
--- /dev/null
+Frame attempted to load mailto:?to=one%40example.org&body=Line+1%0D%0ALine+2%0D%0A%40%26%3D%2C%3B%3F%22
+Field 1: Field 2:
--- /dev/null
+<body onload="test()">
+<form method="get" enctype="text/plain" action="mailto:">
+Field 1: <input type="text" size="10" maxlength="40" name="to" value="one@example.org">
+Field 2: <textarea name="body">Line 1
+Line 2
+@&=,;?"</textarea>
+<input type="submit" value="Send">
+</form>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+Frame attempted to load mailto:nobody@gmail.com?to=one%40example.org&field2=value+2
+Field 1: Field 2:
--- /dev/null
+<body onload="test()">
+<form method="get" enctype="application/x-www-form-urlencoded" action="mailto:nobody@gmail.com">
+Field 1: <input type="text" size="10" maxlength="40" name="to" value="one@example.org">
+Field 2: <input type="text" size="10" maxlength="40" name="field2" value="value 2">
+<input type="submit" value="Send">
+</form>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+<body onload="test()">
+<form method="get" action="mailto:nobody@gmail.com">
+Field 1: <input type="text" size="10" maxlength="40" name="field1" value="value 1">
+Field 2: <input type="text" size="10" maxlength="40" name="field2" value="value 2">
+<input type="submit" value="Send">
+</form>
+<div>Expected results when clicking "Send" button: A new mail message is created with an empty body.</div>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+Frame attempted to load mailto:one@example.org?subject=Fr%C3%A8re+Fran%C3%A7ois&body=%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0
+
--- /dev/null
+Frame attempted to load mailto:one@example.org?subject=Fr%C3%A8re+Fran%C3%A7ois&body=%D0%9F%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%BA%D0%B0
+
--- /dev/null
+<meta charset="utf-8">
+<body onload="test()">
+<form method="get" enctype="text/plain" action="mailto:one@example.org">
+<input type="text" size="10" maxlength="40" name="subject" value="Frère François">
+<input type="text" size="10" maxlength="40" name="body" value="Проверка">
+<input type="submit" value="Send">
+</form>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+<meta charset="utf-8">
+<body onload="test()">
+<form method="get" action="mailto:one@example.org">
+<input type="text" size="10" maxlength="40" name="subject" value="Frère François">
+<input type="text" size="10" maxlength="40" name="body" value="Проверка">
+<input type="submit" value="Send">
+</form>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+Frame attempted to load mailto:nobody@gmail.com?to=someone%40example.org
+
+Expected results when clicking "Send" button: A new mail message is created with an empty body, and two addressees.
--- /dev/null
+<body onload="test()">
+<form method="get" action="mailto:nobody@gmail.com?to=another@example.org&body=Body">
+<input type="text" size="10" maxlength="40" name="to" value="someone@example.org">
+<input type="submit" value="Send">
+</form>
+<div>Expected results when clicking "Send" button: A new mail message is created with an empty body, and two addressees.</div>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+Frame attempted to load mailto:nobody@gmail.com?to=another@example.org&body=Body&body=to%3Dsomeone%2540example.org
+
+Expected results when clicking "Send" button: A new mail message is created with an empty body, and two addressees.
--- /dev/null
+<body onload="test()">
+<form method="post" action="mailto:nobody@gmail.com?to=another@example.org&body=Body">
+<input type="text" size="10" maxlength="40" name="to" value="someone@example.org">
+<input type="submit" value="Send">
+</form>
+<div>Expected results when clicking "Send" button: A new mail message is created with an empty body, and two addressees.</div>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+Frame attempted to load mailto:nobody@gmail.com?body=field1%3Dvalue%2B1%26field2%3Dvalue%2B2
+Field 1: Field 2:
+Expected results when clicking "Send" button: A new mail message is created with a body of "field1=value 1&field2=value 2".
--- /dev/null
+Frame attempted to load mailto:?body=to%3Done%2540example.org%26body%3DLine%2B1%250D%250ALine%2B2%250D%250A%2540%2526%253D%252C%253B%253F%2522
+Field 1: Field 2:
--- /dev/null
+<body onload="test()">
+<form method="post" enctype="multipart/form-data" action="mailto:">
+Field 1: <input type="text" size="10" maxlength="40" name="to" value="one@example.org">
+Field 2: <textarea name="body">Line 1
+Line 2
+@&=,;?"</textarea>
+<input type="submit" value="Send">
+</form>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+Frame attempted to load mailto:?body=to%3Done%40example.org%0D%0Abody%3DLine%201%0D%0ALine%202%0D%0A%40%26%3D%2C%3B%3F%22%2B%0D%0A
+Field 1: Field 2:
--- /dev/null
+<body onload="test()">
+<form method="post" enctype="text/plain" action="mailto:">
+Field 1: <input type="text" size="10" maxlength="40" name="to" value="one@example.org">
+Field 2: <textarea name="body">Line 1
+Line 2
+@&=,;?"+</textarea>
+<input type="submit" value="Send">
+</form>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+Frame attempted to load mailto:?body=to%3Done%2540example.org%26body%3DLine%2B1%250D%250ALine%2B2%250D%250A%2540%2526%253D%252C%253B%253F%2522
+Field 1: Field 2:
--- /dev/null
+<body onload="test()">
+<form method="post" enctype="application/x-www-form-urlencoded" action="mailto:">
+Field 1: <input type="text" size="10" maxlength="40" name="to" value="one@example.org">
+Field 2: <textarea name="body">Line 1
+Line 2
+@&=,;?"</textarea>
+<input type="submit" value="Send">
+</form>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
--- /dev/null
+<body onload="test()">
+<form method="post" action="mailto:nobody@gmail.com">
+Field 1: <input type="text" size="10" maxlength="40" name="field1" value="value 1">
+Field 2: <input type="text" size="10" maxlength="40" name="field2" value="value 2">
+<input type="submit" value="Send">
+</form>
+<div>Expected results when clicking "Send" button: A new mail message is created with a body of "field1=value 1&field2=value 2".</div>
+<script>
+function test() {
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.setCustomPolicyDelegate(true);
+ document.getElementsByTagName("form")[0].submit();
+ layoutTestController.setCustomPolicyDelegate(false);
+ }
+}
+</script>
+2008-01-02 Alexey Proskuryakov <ap@webkit.org>
+
+ 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):
+
2008-01-02 Mark Rowe <mrowe@apple.com>
Autotools build fix.
firstSuccessfulSubmitButton->setActivatedSubmit(true);
if (m_post) {
- if (!m_multipart)
- frame->loader()->submitForm("POST", m_url, formData(0), m_target, enctype(), String(), event);
- else {
+ bool isMailtoForm = m_url.startsWith("mailto:", false);
+ if (m_multipart && isMailtoForm) {
+ setEnctype("application/x-www-form-urlencoded");
+ m_multipart = false;
+ }
+
+ if (!m_multipart) {
+ RefPtr<FormData> data = formData(0);
+ if (isMailtoForm) {
+ String body = data->flattenToString();
+ if (equalIgnoringCase(enctype(), "text/plain")) {
+ // Convention seems to be to decode, and s/&/\r\n/. Also, spaces are encoded as %20.
+ body = KURL::decode_string(body.replace('&', "\r\n").replace('+', ' ').deprecatedString() + "\r\n");
+ }
+ data = new FormData((String("body=") + encodeCString(body.latin1())).replace('+', "%20").latin1());
+ }
+ frame->loader()->submitForm("POST", m_url, data, m_target, enctype(), String(), event);
+ } else {
Vector<char> boundary;
getUniqueBoundaryString(boundary);
frame->loader()->submitForm("POST", m_url, formData(boundary.data()), m_target, enctype(), boundary.data(), event);
frameRequest.setFrameName(target.isEmpty() ? m_frame->document()->baseTarget() : target);
// Handle mailto: forms
- bool mailtoForm = u.protocol() == "mailto";
- if (mailtoForm) {
- // Append body=
- String body;
- if (equalIgnoringCase(contentType, "multipart/form-data"))
- // FIXME: is this correct? I suspect not, but what site can we test this on?
- body = formData->flattenToString();
- else if (equalIgnoringCase(contentType, "text/plain"))
- // Convention seems to be to decode, and s/&/\n/
- body = KURL::decode_string(
- formData->flattenToString().replace('&', '\n')
- .replace('+', ' ').deprecatedString()); // Recode for the URL
- else
- body = formData->flattenToString();
-
+ bool isMailtoForm = equalIgnoringCase(u.protocol(), "mailto");
+ if (isMailtoForm && strcmp(action, "GET") != 0) {
+ // Append body= for POST mailto, replace the whole query string for GET one.
+ String body = formData->flattenToString();
String query = u.query();
if (!query.isEmpty())
query.append('&');
- u.setQuery((query + "body=" + KURL::encode_string(body.deprecatedString())).deprecatedString());
+ u.setQuery((query + body).deprecatedString());
}
if (strcmp(action, "GET") == 0) {
- if (!mailtoForm)
- u.setQuery(formData->flattenToString().deprecatedString());
+ u.setQuery(formData->flattenToString().deprecatedString());
} else {
- frameRequest.resourceRequest().setHTTPBody(formData.get());
+ if (!isMailtoForm)
+ frameRequest.resourceRequest().setHTTPBody(formData.get());
frameRequest.resourceRequest().setHTTPMethod("POST");
// construct some user headers if necessary