Title: [98172] trunk
Revision
98172
Author
commit-qu...@webkit.org
Date
2011-10-21 17:04:18 -0700 (Fri, 21 Oct 2011)

Log Message

Setting form.enctype reflected attribute behaves strangely.
https://bugs.webkit.org/show_bug.cgi?id=44879

Patch by Vineet Chaudhary <vineet.chaudh...@motorola.com> on 2011-10-21
Reviewed by Darin Adler.

Source/WebCore:

The spec says form.enctype should be application/x-www-form-urlencoded,
So as "text", "plain", "multipart" or "form-data" these are not a valid value so must be ignored.

* loader/FormSubmission.cpp:
(WebCore::FormSubmission::Attributes::parseEncodingType):

LayoutTests:

Leading/trailing white-spaces should not be allowed while specifying attribute value.
Added more test coverage for form.enctype attribute.

* fast/forms/encoding-test.html:
* fast/forms/enctype-attribute-expected.txt:
* fast/forms/enctype-attribute.html: Corrected test case as per new behavior.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98171 => 98172)


--- trunk/LayoutTests/ChangeLog	2011-10-22 00:01:58 UTC (rev 98171)
+++ trunk/LayoutTests/ChangeLog	2011-10-22 00:04:18 UTC (rev 98172)
@@ -1,3 +1,17 @@
+2011-10-21  Vineet Chaudhary  <vineet.chaudh...@motorola.com>
+
+        Setting form.enctype reflected attribute behaves strangely.
+        https://bugs.webkit.org/show_bug.cgi?id=44879
+
+        Reviewed by Darin Adler.
+
+        Leading/trailing white-spaces should not be allowed while specifying attribute value.
+        Added more test coverage for form.enctype attribute.
+
+        * fast/forms/encoding-test.html:
+        * fast/forms/enctype-attribute-expected.txt:
+        * fast/forms/enctype-attribute.html: Corrected test case as per new behavior.
+
 2011-10-21  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Gardening update.

Modified: trunk/LayoutTests/fast/forms/encoding-test.html (98171 => 98172)


--- trunk/LayoutTests/fast/forms/encoding-test.html	2011-10-22 00:01:58 UTC (rev 98171)
+++ trunk/LayoutTests/fast/forms/encoding-test.html	2011-10-22 00:04:18 UTC (rev 98172)
@@ -2,6 +2,6 @@
 <input type=text>
 </form>
 <script>
-document.forms[0].enctype = 'multipart/formdata';
+document.forms[0].enctype = 'multipart/form-data';
 document.write(document.forms[0].encoding);
 </script>

Modified: trunk/LayoutTests/fast/forms/enctype-attribute-expected.txt (98171 => 98172)


--- trunk/LayoutTests/fast/forms/enctype-attribute-expected.txt	2011-10-22 00:01:58 UTC (rev 98171)
+++ trunk/LayoutTests/fast/forms/enctype-attribute-expected.txt	2011-10-22 00:04:18 UTC (rev 98172)
@@ -9,14 +9,59 @@
 PASS form1.getAttribute("enctype") is "foobar"
 PASS form1.setAttribute("enctype", "baz"); form1.enctype is "application/x-www-form-urlencoded"
 
+Text and its subtypes:
+PASS form1.enctype = "text"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "plain"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/1d-interleaved-parityfec"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/calendar"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/css"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/csv"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/dns"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/enriched"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/example"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/fwdred"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/html"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/rfc822-headers"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/richtext"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/rtx"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/sgml"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/t140"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/troff"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/ulpfec"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/uri-list"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/vcard"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/xml"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "text/xml-external-parsed-entity"; form1.enctype is "application/x-www-form-urlencoded"
+
+Multipart and its subtypes:
+PASS form1.enctype = "multipart"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "form-data"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/mixed"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/message"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/digest"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/alternative"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/alternative"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/byteranges"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/encrypted"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/example"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/parallel"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/related"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/report"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.enctype = "multipart/signed"; form1.enctype is "application/x-www-form-urlencoded"
+
 Valid values:
 PASS form1.enctype = "Text/Plain"; form1.enctype is "text/plain"
 PASS form1.getAttribute("enctype") is "Text/Plain"
 PASS form1.setAttribute("enctype", "Text/Plain"); form1.enctype is "text/plain"
+PASS form1.enctype = "Multipart/Form-Data"; form1.enctype is "multipart/form-data"
+PASS form1.getAttribute("enctype") is "Multipart/Form-Data"
+PASS form1.setAttribute("enctype", "Multipart/Form-Data"); form1.enctype is "multipart/form-data"
 
-Valid values with whitespace:
-PASS form1.enctype = "  multipart/form-data"; form1.enctype is "multipart/form-data"
+Values with whitespace:
+PASS form1.enctype = "  multipart/form-data"; form1.enctype is "application/x-www-form-urlencoded"
 PASS form1.getAttribute("enctype") is "  multipart/form-data"
+PASS form1.enctype = "multipart/form-data  "; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.getAttribute("enctype") is "multipart/form-data  "
 PASS form1.enctype = "application/x-www-form-urlencoded "; form1.enctype is "application/x-www-form-urlencoded"
 
 PASS successfullyParsed is true

Modified: trunk/LayoutTests/fast/forms/enctype-attribute.html (98171 => 98172)


--- trunk/LayoutTests/fast/forms/enctype-attribute.html	2011-10-22 00:01:58 UTC (rev 98171)
+++ trunk/LayoutTests/fast/forms/enctype-attribute.html	2011-10-22 00:04:18 UTC (rev 98172)
@@ -20,19 +20,65 @@
 shouldBe('form1.enctype = "foobar"; form1.enctype', '"application/x-www-form-urlencoded"');
 shouldBe('form1.getAttribute("enctype")', '"foobar"');
 shouldBe('form1.setAttribute("enctype", "baz"); form1.enctype', '"application/x-www-form-urlencoded"');
+debug('');
+debug('Text and its subtypes:');
+shouldBe('form1.enctype = "text"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "plain"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/1d-interleaved-parityfec"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/calendar"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/css"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/csv"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/dns"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/enriched"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/example"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/fwdred"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/html"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/rfc822-headers"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/richtext"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/rtx"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/sgml"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/t140"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/troff"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/ulpfec"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/uri-list"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/vcard"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/xml"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "text/xml-external-parsed-entity"; form1.enctype', '"application/x-www-form-urlencoded"');
+debug('');
+debug('Multipart and its subtypes:');
+shouldBe('form1.enctype = "multipart"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "form-data"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/mixed"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/message"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/digest"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/alternative"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/alternative"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/byteranges"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/encrypted"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/example"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/parallel"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/related"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/report"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.enctype = "multipart/signed"; form1.enctype', '"application/x-www-form-urlencoded"');
 
 debug('');
 debug('Valid values:');
 shouldBe('form1.enctype = "Text/Plain"; form1.enctype', '"text/plain"');
 shouldBe('form1.getAttribute("enctype")', '"Text/Plain"');
 shouldBe('form1.setAttribute("enctype", "Text/Plain"); form1.enctype', '"text/plain"');
+shouldBe('form1.enctype = "Multipart/Form-Data"; form1.enctype', '"multipart/form-data"');
+shouldBe('form1.getAttribute("enctype")', '"Multipart/Form-Data"');
+shouldBe('form1.setAttribute("enctype", "Multipart/Form-Data"); form1.enctype', '"multipart/form-data"');
 
+
 debug('');
-debug('Valid values with whitespace:');
+debug('Values with whitespace:');
 // Note: IE9 thorws "Invalid argument.", Firefox 6 doesn't allow leading whitespace.
 // Firefox matches to the specification.
-shouldBe('form1.enctype = "  multipart/form-data"; form1.enctype', '"multipart/form-data"');
+shouldBe('form1.enctype = "  multipart/form-data"; form1.enctype', '"application/x-www-form-urlencoded"');
 shouldBe('form1.getAttribute("enctype")', '"  multipart/form-data"');
+shouldBe('form1.enctype = "multipart/form-data  "; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.getAttribute("enctype")', '"multipart/form-data  "');
 
 shouldBe('form1.enctype = "application/x-www-form-urlencoded "; form1.enctype', '"application/x-www-form-urlencoded"');
 

Modified: trunk/Source/WebCore/ChangeLog (98171 => 98172)


--- trunk/Source/WebCore/ChangeLog	2011-10-22 00:01:58 UTC (rev 98171)
+++ trunk/Source/WebCore/ChangeLog	2011-10-22 00:04:18 UTC (rev 98172)
@@ -1,3 +1,16 @@
+2011-10-21  Vineet Chaudhary  <vineet.chaudh...@motorola.com>
+
+        Setting form.enctype reflected attribute behaves strangely.
+        https://bugs.webkit.org/show_bug.cgi?id=44879
+
+        Reviewed by Darin Adler.
+
+        The spec says form.enctype should be application/x-www-form-urlencoded,
+        So as "text", "plain", "multipart" or "form-data" these are not a valid value so must be ignored.
+
+        * loader/FormSubmission.cpp:
+        (WebCore::FormSubmission::Attributes::parseEncodingType):
+
 2011-10-21  Matthew Delaney  <mdela...@apple.com>
 
         Ensure periodic flushing of canvas drawing context

Modified: trunk/Source/WebCore/loader/FormSubmission.cpp (98171 => 98172)


--- trunk/Source/WebCore/loader/FormSubmission.cpp	2011-10-22 00:01:58 UTC (rev 98171)
+++ trunk/Source/WebCore/loader/FormSubmission.cpp	2011-10-22 00:04:18 UTC (rev 98172)
@@ -90,9 +90,9 @@
 
 String FormSubmission::Attributes::parseEncodingType(const String& type)
 {
-    if (type.contains("multipart", false) || type.contains("form-data", false))
+    if (equalIgnoringCase(type, "multipart/form-data"))
         return "multipart/form-data";
-    if (type.contains("text", false) || type.contains("plain", false))
+    if (equalIgnoringCase(type, "text/plain"))
         return "text/plain";
     return "application/x-www-form-urlencoded";
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to