Reviewed by Darin.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Jan 2008 17:34:41 +0000 (17:34 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Jan 2008 17:34:41 +0000 (17:34 +0000)
        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

30 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/mailto/advanced-get-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/advanced-get.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/advanced-put-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/advanced-put.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-multiple-items-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-multiple-items-text-plain-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-multiple-items-text-plain.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-multiple-items-x-www-form-urlencoded-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-multiple-items.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-non-ascii-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-non-ascii-text-plain-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-non-ascii-text-plain.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-non-ascii.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-overwrite-query-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/get-overwrite-query.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-append-query-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-append-query.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-multiple-items-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-multiple-items-multipart-form-data-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-multiple-items-multipart-form-data.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-multiple-items-text-plain-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-multiple-items-text-plain.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-multiple-items-x-www-form-urlencoded-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html [new file with mode: 0644]
LayoutTests/fast/forms/mailto/post-multiple-items.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLFormElement.cpp
WebCore/loader/FrameLoader.cpp

index f0c36df363af318605fc55e2ab07d1aeaeac8220..594b2f9cfda78d406569e40c84b61af0054d7bc3 100644 (file)
@@ -1,3 +1,41 @@
+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.
diff --git a/LayoutTests/fast/forms/mailto/advanced-get-expected.txt b/LayoutTests/fast/forms/mailto/advanced-get-expected.txt
new file mode 100644 (file)
index 0000000..c3bcb2b
--- /dev/null
@@ -0,0 +1,4 @@
+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.
+
+         
diff --git a/LayoutTests/fast/forms/mailto/advanced-get.html b/LayoutTests/fast/forms/mailto/advanced-get.html
new file mode 100644 (file)
index 0000000..f974700
--- /dev/null
@@ -0,0 +1,30 @@
+<!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&amp;m;?=">
+<textarea name="body">line1
+line2
+line3
+line4</textarea>
+            <input type="submit" value="Compose">
+        </form>
+    </body>
+</html>
diff --git a/LayoutTests/fast/forms/mailto/advanced-put-expected.txt b/LayoutTests/fast/forms/mailto/advanced-put-expected.txt
new file mode 100644 (file)
index 0000000..c3bcb2b
--- /dev/null
@@ -0,0 +1,4 @@
+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.
+
+         
diff --git a/LayoutTests/fast/forms/mailto/advanced-put.html b/LayoutTests/fast/forms/mailto/advanced-put.html
new file mode 100644 (file)
index 0000000..fe07128
--- /dev/null
@@ -0,0 +1,30 @@
+<!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&amp;m;?=">
+<textarea name="body">line1
+line2
+line3
+line4</textarea>
+            <input type="submit" value="Compose">
+        </form>
+    </body>
+</html>
diff --git a/LayoutTests/fast/forms/mailto/get-multiple-items-expected.txt b/LayoutTests/fast/forms/mailto/get-multiple-items-expected.txt
new file mode 100644 (file)
index 0000000..9d4a470
--- /dev/null
@@ -0,0 +1,3 @@
+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.
diff --git a/LayoutTests/fast/forms/mailto/get-multiple-items-text-plain-expected.txt b/LayoutTests/fast/forms/mailto/get-multiple-items-text-plain-expected.txt
new file mode 100644 (file)
index 0000000..d5c35db
--- /dev/null
@@ -0,0 +1,2 @@
+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:  
diff --git a/LayoutTests/fast/forms/mailto/get-multiple-items-text-plain.html b/LayoutTests/fast/forms/mailto/get-multiple-items-text-plain.html
new file mode 100644 (file)
index 0000000..6dd7b0d
--- /dev/null
@@ -0,0 +1,18 @@
+<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
+@&amp;=,;?"</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>
diff --git a/LayoutTests/fast/forms/mailto/get-multiple-items-x-www-form-urlencoded-expected.txt b/LayoutTests/fast/forms/mailto/get-multiple-items-x-www-form-urlencoded-expected.txt
new file mode 100644 (file)
index 0000000..79dfc54
--- /dev/null
@@ -0,0 +1,2 @@
+Frame  attempted to load mailto:nobody@gmail.com?to=one%40example.org&field2=value+2
+Field 1:  Field 2:  
diff --git a/LayoutTests/fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html b/LayoutTests/fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html
new file mode 100644 (file)
index 0000000..1245394
--- /dev/null
@@ -0,0 +1,16 @@
+<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>
diff --git a/LayoutTests/fast/forms/mailto/get-multiple-items.html b/LayoutTests/fast/forms/mailto/get-multiple-items.html
new file mode 100644 (file)
index 0000000..2243589
--- /dev/null
@@ -0,0 +1,17 @@
+<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>
diff --git a/LayoutTests/fast/forms/mailto/get-non-ascii-expected.txt b/LayoutTests/fast/forms/mailto/get-non-ascii-expected.txt
new file mode 100644 (file)
index 0000000..19b5fa2
--- /dev/null
@@ -0,0 +1,2 @@
+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
+  
diff --git a/LayoutTests/fast/forms/mailto/get-non-ascii-text-plain-expected.txt b/LayoutTests/fast/forms/mailto/get-non-ascii-text-plain-expected.txt
new file mode 100644 (file)
index 0000000..19b5fa2
--- /dev/null
@@ -0,0 +1,2 @@
+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
+  
diff --git a/LayoutTests/fast/forms/mailto/get-non-ascii-text-plain.html b/LayoutTests/fast/forms/mailto/get-non-ascii-text-plain.html
new file mode 100644 (file)
index 0000000..2b282b8
--- /dev/null
@@ -0,0 +1,17 @@
+<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&egrave;re Fran&ccedil;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>
diff --git a/LayoutTests/fast/forms/mailto/get-non-ascii.html b/LayoutTests/fast/forms/mailto/get-non-ascii.html
new file mode 100644 (file)
index 0000000..2163245
--- /dev/null
@@ -0,0 +1,17 @@
+<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&egrave;re Fran&ccedil;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>
diff --git a/LayoutTests/fast/forms/mailto/get-overwrite-query-expected.txt b/LayoutTests/fast/forms/mailto/get-overwrite-query-expected.txt
new file mode 100644 (file)
index 0000000..a6d97ff
--- /dev/null
@@ -0,0 +1,3 @@
+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.
diff --git a/LayoutTests/fast/forms/mailto/get-overwrite-query.html b/LayoutTests/fast/forms/mailto/get-overwrite-query.html
new file mode 100644 (file)
index 0000000..bffe7ac
--- /dev/null
@@ -0,0 +1,16 @@
+<body onload="test()">
+<form method="get" action="mailto:nobody@gmail.com?to=another@example.org&amp;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>
diff --git a/LayoutTests/fast/forms/mailto/post-append-query-expected.txt b/LayoutTests/fast/forms/mailto/post-append-query-expected.txt
new file mode 100644 (file)
index 0000000..d4387e2
--- /dev/null
@@ -0,0 +1,3 @@
+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.
diff --git a/LayoutTests/fast/forms/mailto/post-append-query.html b/LayoutTests/fast/forms/mailto/post-append-query.html
new file mode 100644 (file)
index 0000000..6fd130f
--- /dev/null
@@ -0,0 +1,16 @@
+<body onload="test()">
+<form method="post" action="mailto:nobody@gmail.com?to=another@example.org&amp;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>
diff --git a/LayoutTests/fast/forms/mailto/post-multiple-items-expected.txt b/LayoutTests/fast/forms/mailto/post-multiple-items-expected.txt
new file mode 100644 (file)
index 0000000..116d675
--- /dev/null
@@ -0,0 +1,3 @@
+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".
diff --git a/LayoutTests/fast/forms/mailto/post-multiple-items-multipart-form-data-expected.txt b/LayoutTests/fast/forms/mailto/post-multiple-items-multipart-form-data-expected.txt
new file mode 100644 (file)
index 0000000..66170e5
--- /dev/null
@@ -0,0 +1,2 @@
+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:  
diff --git a/LayoutTests/fast/forms/mailto/post-multiple-items-multipart-form-data.html b/LayoutTests/fast/forms/mailto/post-multiple-items-multipart-form-data.html
new file mode 100644 (file)
index 0000000..b0d970a
--- /dev/null
@@ -0,0 +1,18 @@
+<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
+@&amp;=,;?"</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>
diff --git a/LayoutTests/fast/forms/mailto/post-multiple-items-text-plain-expected.txt b/LayoutTests/fast/forms/mailto/post-multiple-items-text-plain-expected.txt
new file mode 100644 (file)
index 0000000..0428898
--- /dev/null
@@ -0,0 +1,2 @@
+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:  
diff --git a/LayoutTests/fast/forms/mailto/post-multiple-items-text-plain.html b/LayoutTests/fast/forms/mailto/post-multiple-items-text-plain.html
new file mode 100644 (file)
index 0000000..253b9c6
--- /dev/null
@@ -0,0 +1,18 @@
+<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
+@&amp;=,;?"+</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>
diff --git a/LayoutTests/fast/forms/mailto/post-multiple-items-x-www-form-urlencoded-expected.txt b/LayoutTests/fast/forms/mailto/post-multiple-items-x-www-form-urlencoded-expected.txt
new file mode 100644 (file)
index 0000000..66170e5
--- /dev/null
@@ -0,0 +1,2 @@
+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:  
diff --git a/LayoutTests/fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html b/LayoutTests/fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html
new file mode 100644 (file)
index 0000000..7216bcf
--- /dev/null
@@ -0,0 +1,18 @@
+<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
+@&amp;=,;?"</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>
diff --git a/LayoutTests/fast/forms/mailto/post-multiple-items.html b/LayoutTests/fast/forms/mailto/post-multiple-items.html
new file mode 100644 (file)
index 0000000..24e80df
--- /dev/null
@@ -0,0 +1,17 @@
+<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>
index 9f5117f2eb8a2074c79691eb5fccf405b0ff8f94..98395ddf90ba3203f7487bdd10c9cd67c4482bbe 100644 (file)
@@ -1,3 +1,35 @@
+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.
index c2d7b15b2880bf97197b2d49fd4e561d5f49eb74..71b41c4bbd648e41ceb1cea6234b17b6b106e3fc 100644 (file)
@@ -474,9 +474,24 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton)
         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);
index 030069128aa73931dfa6b5dfe0d9be18aa7d1c33..c5e55386317eb3088cdcd10895d40c7bfddcf698 100644 (file)
@@ -539,32 +539,21 @@ void FrameLoader::submitForm(const char* action, const String& url, PassRefPtr<F
     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