Title: [170530] trunk
Revision
170530
Author
[email protected]
Date
2014-06-27 09:01:33 -0700 (Fri, 27 Jun 2014)

Log Message

[XHR] open method must uppercase only standard method types
https://bugs.webkit.org/show_bug.cgi?id=134264

Patch by Mahesh Kulkarni <[email protected]> on 2014-06-27
Reviewed by Darin Adler.

Source/WebCore:
As per step-5 of http://xhr.spec.whatwg.org/#the-open()-method only
DELETE, PUT, GET, POST, OPTIONS, HEAD are standard. Use other methods as is without case change.
All tests from w3c-test suite pass http://w3c-test.org/XMLHttpRequest/open-method-case-sensitive.htm.
This merges blink changes from r176592.

Tests: http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed.html
       http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive.html

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::uppercaseKnownHTTPMethod):

LayoutTests:
All tests from w3c-test suite pass http://w3c-test.org/XMLHttpRequest/open-method-case-sensitive.htm.
This merges blink changes from r176592.

* http/tests/xmlhttprequest/resources/echo-request-method.php: Added.
* http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed-expected.txt: Added.
* http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed.html: Added.
* http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive-expected.txt: Added.
* http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (170529 => 170530)


--- trunk/LayoutTests/ChangeLog	2014-06-27 15:51:01 UTC (rev 170529)
+++ trunk/LayoutTests/ChangeLog	2014-06-27 16:01:33 UTC (rev 170530)
@@ -1,3 +1,19 @@
+2014-06-27  Mahesh Kulkarni  <[email protected]>
+
+        [XHR] open method must uppercase only standard method types
+        https://bugs.webkit.org/show_bug.cgi?id=134264
+
+        Reviewed by Darin Adler.
+
+        All tests from w3c-test suite pass http://w3c-test.org/XMLHttpRequest/open-method-case-sensitive.htm.
+        This merges blink changes from r176592.
+
+        * http/tests/xmlhttprequest/resources/echo-request-method.php: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed-expected.txt: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed.html: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive-expected.txt: Added.
+        * http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive.html: Added.
+
 2014-06-26  Benjamin Poulain  <[email protected]>
 
         iOS 8 beta 2 ES6 'Set' clear() broken

Added: trunk/LayoutTests/http/tests/xmlhttprequest/resources/echo-request-method.php (0 => 170530)


--- trunk/LayoutTests/http/tests/xmlhttprequest/resources/echo-request-method.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/resources/echo-request-method.php	2014-06-27 16:01:33 UTC (rev 170530)
@@ -0,0 +1,6 @@
+<?php
+if ($_SERVER['REQUEST_METHOD'])
+    header("X-CUSTOM-REQUEST-METHOD: " . $_SERVER['REQUEST_METHOD']);
+else 
+    header("X-CUSTOM-REQUEST-METHOD: NOT_SET");
+?>  

Added: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed-expected.txt (0 => 170530)


--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed-expected.txt	2014-06-27 16:01:33 UTC (rev 170530)
@@ -0,0 +1,16 @@
+Valid methods per step-5 of http://xhr.spec.whatwg.org/#the-open()-method.
+
+
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 1 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 2 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 3 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 4 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 5 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 6 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 7 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 8 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 9 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 10 
+PASS XMLHttpRequest: open() - allowed case in/sensitive methods test 11 
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed.html (0 => 170530)


--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed.html	2014-06-27 16:01:33 UTC (rev 170530)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>XMLHttpRequest: open() - allowed case in/sensitive methods test</title>
+    <script src=""
+    <script src=""
+  </head>
+  <body>
+    <p>Valid methods per step-5 of http://xhr.spec.whatwg.org/#the-open()-method.</p>
+    <script type="text/_javascript_">
+      function testMethod(methodName) {
+        var client = new XMLHttpRequest();
+        client.open(methodName, "resources/echo-request-method.php");
+        client._onreadystatechange_ = function(event) {
+          if (event.target.readyState == 4)
+            assert_equals(client.getResponseHeader("x-custom-request-method"), methodName.toUpperCase());
+        }
+        client.send(null);
+      }
+
+      test(function() { testMethod("PUT"); });
+      test(function() { testMethod("Put"); });
+      test(function() { testMethod("DELETE"); });
+      test(function() { testMethod("DeLeTe"); });
+      test(function() { testMethod("HEAD"); });
+      test(function() { testMethod("hEAd"); });
+      test(function() { testMethod("OPTIONS"); });
+      test(function() { testMethod("OPtiOns"); });
+      test(function() { testMethod("POST"); });
+      test(function() { testMethod("post"); });
+      test(function() { testMethod("GET"); });
+      test(function() { testMethod("gEt"); });
+    </script>
+  </body>
+</html>
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive-expected.txt (0 => 170530)


--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive-expected.txt	2014-06-27 16:01:33 UTC (rev 170530)
@@ -0,0 +1,13 @@
+non-standard method names should be returned as is per step-5 of http://xhr.spec.whatwg.org/#the-open()-method.
+
+
+PASS XMLHttpRequest: open() - case-insensitive methods test 
+PASS XMLHttpRequest: open() - case-insensitive methods test 1 
+PASS XMLHttpRequest: open() - case-insensitive methods test 2 
+PASS XMLHttpRequest: open() - case-insensitive methods test 3 
+PASS XMLHttpRequest: open() - case-insensitive methods test 4 
+PASS XMLHttpRequest: open() - case-insensitive methods test 5 
+PASS XMLHttpRequest: open() - case-insensitive methods test 6 
+PASS XMLHttpRequest: open() - case-insensitive methods test 7 
+PASS XMLHttpRequest: open() - case-insensitive methods test 8 
+

Added: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive.html (0 => 170530)


--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive.html	2014-06-27 16:01:33 UTC (rev 170530)
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>XMLHttpRequest: open() - case-insensitive methods test</title>
+    <script src=""
+    <script src=""
+  </head>
+  <body>
+    <p>non-standard method names should be returned as is per step-5 of http://xhr.spec.whatwg.org/#the-open()-method.</p>
+    <script type="text/_javascript_">
+      function testMethod(methodName, lastTest) {
+        var client = new XMLHttpRequest();
+        client.open(methodName, "resources/echo-request-method.php");
+        client._onreadystatechange_ = function(event) {
+          if (event.target.readyState == 4)
+            assert_equals(client.getResponseHeader("x-custom-request-method"), methodName);
+        }
+        client.send(null);
+      }
+
+      test(function() { testMethod("XUNICORN"); });
+      test(function() { testMethod("xUNIcorn"); });
+      test(function() { testMethod("chiCKEN"); });
+      test(function() { testMethod("PATCH"); });
+      test(function() { testMethod("patCH"); });
+      test(function() { testMethod("copy"); });
+      test(function() { testMethod("COpy"); });
+      test(function() { testMethod("inDEX"); });
+      test(function() { testMethod("movE"); });
+    </script>
+  </body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (170529 => 170530)


--- trunk/Source/WebCore/ChangeLog	2014-06-27 15:51:01 UTC (rev 170529)
+++ trunk/Source/WebCore/ChangeLog	2014-06-27 16:01:33 UTC (rev 170530)
@@ -1,3 +1,21 @@
+2014-06-27  Mahesh Kulkarni  <[email protected]>
+
+        [XHR] open method must uppercase only standard method types
+        https://bugs.webkit.org/show_bug.cgi?id=134264
+
+        Reviewed by Darin Adler.
+
+        As per step-5 of http://xhr.spec.whatwg.org/#the-open()-method only
+        DELETE, PUT, GET, POST, OPTIONS, HEAD are standard. Use other methods as is without case change.
+        All tests from w3c-test suite pass http://w3c-test.org/XMLHttpRequest/open-method-case-sensitive.htm.
+        This merges blink changes from r176592.
+
+        Tests: http/tests/xmlhttprequest/xmlhttprequest-open-method-allowed.html
+               http/tests/xmlhttprequest/xmlhttprequest-open-method-case-insensitive.html
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::uppercaseKnownHTTPMethod):
+
 2014-06-27  Andre Moreira Magalhaes   <[email protected]>
 
         Increase priority on SharedTimer source.

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (170529 => 170530)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2014-06-27 15:51:01 UTC (rev 170529)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2014-06-27 16:01:33 UTC (rev 170530)
@@ -394,7 +394,7 @@
 
 String XMLHttpRequest::uppercaseKnownHTTPMethod(const String& method)
 {
-    const char* const methods[] = { "COPY", "DELETE", "GET", "HEAD", "INDEX", "LOCK", "M-POST", "MKCOL", "MOVE", "OPTIONS", "POST", "PROPFIND", "PROPPATCH", "PUT", "UNLOCK" };
+    const char* const methods[] = { "DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT" };
     for (unsigned i = 0; i < WTF_ARRAY_LENGTH(methods); ++i) {
         if (equalIgnoringCase(method, methods[i])) {
             // Don't bother allocating a new string if it's already all uppercase.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to