Reviewed by George Staikos.
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Dec 2008 01:29:05 +0000 (01:29 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Dec 2008 01:29:05 +0000 (01:29 +0000)
Fixes: https://bugs.webkit.org/show_bug.cgi?id=22971

Fix regression caused by the HTMLFormElement refactorization.
File form elements without a name have to be included in multipart/form-data
submission. Cover this behaviour with a new test case.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39445 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/misc/empty-file-formdata-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/empty-file-formdata.html [new file with mode: 0644]
LayoutTests/http/tests/misc/resources/check-unnamed-file-included-in-formdata.php [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLFormElement.cpp

index 1653837..2a1eba8 100644 (file)
@@ -1,3 +1,17 @@
+2008-12-22  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
+        Reviewed by George Staikos.
+
+        Fixes: https://bugs.webkit.org/show_bug.cgi?id=22971
+
+        Fix regression caused by the HTMLFormElement refactorization.
+        File form elements without a name have to be included in multipart/form-data
+        submission. Cover this behaviour with a new test case.
+
+        * http/tests/misc/empty-file-formdata-expected.txt: Added.
+        * http/tests/misc/empty-file-formdata.html: Added.
+        * http/tests/misc/resources/check-unnamed-file-included-in-formdata.php: Added.
+
 2008-12-22  David Kilzer  <ddkilzer@apple.com>
 
         Bug 11850: Webarchive fails to save images referenced in CSS
diff --git a/LayoutTests/http/tests/misc/empty-file-formdata-expected.txt b/LayoutTests/http/tests/misc/empty-file-formdata-expected.txt
new file mode 100644 (file)
index 0000000..00830dd
--- /dev/null
@@ -0,0 +1,3 @@
+This tests verifies that files without a name are included in the multipart form data:
+
+Test passed.
diff --git a/LayoutTests/http/tests/misc/empty-file-formdata.html b/LayoutTests/http/tests/misc/empty-file-formdata.html
new file mode 100644 (file)
index 0000000..529c286
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head>
+<script>
+function test()
+{
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+
+    document.forms[0].submit();
+}
+
+window.onload = test;
+</script>
+</head>
+<body>
+<form enctype="multipart/form-data" method="POST" action="resources/check-unnamed-file-included-in-formdata.php">
+<input name="data" type="file"></input>
+</form>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/misc/resources/check-unnamed-file-included-in-formdata.php b/LayoutTests/http/tests/misc/resources/check-unnamed-file-included-in-formdata.php
new file mode 100644 (file)
index 0000000..09d5b28
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+header("Content-Type: text/html; charset=UTF-8");
+?>
+<html>
+<head>
+<script>
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+</script>
+</head>
+<body>
+<h1>This tests verifies that files without a name are included in the multipart form data:</h1>
+<pre>
+<?php
+if (isset($_FILES['data'])) {
+    print "Test passed.";
+} else {
+    print "Test failed.";
+}
+?>
+</pre>
+</body>
+</html>
index 38657bd..9275aac 100644 (file)
@@ -1,3 +1,19 @@
+2008-12-22  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
+        Reviewed by George Staikos.
+
+        Fixes: https://bugs.webkit.org/show_bug.cgi?id=22971
+
+        Fix regression caused by the HTMLFormElement refactorization.
+        File form elements without a name have to be included in multipart/form-data
+        submission. Cover this behaviour with a new test case.
+
+        Test: http/tests/misc/empty-file-formdata.html
+
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::createFormData):
+        * wml/WMLTagNames.in:
+
 2008-12-22  David Kilzer  <ddkilzer@apple.com>
 
         <rdar://problem/6438298> Bump schema version for app cache
index e71a50a..9288765 100644 (file)
@@ -207,9 +207,11 @@ PassRefPtr<FormData> HTMLFormElement::createFormData(const CString& boundary)
                             }
                         }
 
-                        if (!fileName.isEmpty()) {
-                            m_formDataBuilder.addFilenameToMultiPartHeader(header, encoding, fileName);
+                        // We have to include the filename=".." part in the header, even if the filename is empty
+                        // Covered by LayoutTests/http/tests/misc/empty-file-formdata.html
+                        m_formDataBuilder.addFilenameToMultiPartHeader(header, encoding, fileName);
 
+                        if (!fileName.isEmpty()) {
                             // FIXME: The MIMETypeRegistry function's name makes it sound like it takes a path,
                             // not just a basename. But filename is not the path. But note that it's not safe to
                             // just use path instead since in the generated-file case it will not reflect the