Title: [246559] trunk
Revision
246559
Author
drou...@apple.com
Date
2019-06-18 12:37:35 -0700 (Tue, 18 Jun 2019)

Log Message

Web Inspector: parseQueryParameters fails to successfully parse query parameter values that contain "="
https://bugs.webkit.org/show_bug.cgi?id=198971
<rdar://problem/51852782>

Reviewed by Joseph Pecoraro.

Source/WebInspectorUI:

* UserInterface/Base/URLUtilities.js:
(parseQueryString):

LayoutTests:

* inspector/unit-tests/url-utilities.html:
* inspector/unit-tests/url-utilities-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (246558 => 246559)


--- trunk/LayoutTests/ChangeLog	2019-06-18 19:33:41 UTC (rev 246558)
+++ trunk/LayoutTests/ChangeLog	2019-06-18 19:37:35 UTC (rev 246559)
@@ -1,3 +1,14 @@
+2019-06-18  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: parseQueryParameters fails to successfully parse query parameter values that contain "="
+        https://bugs.webkit.org/show_bug.cgi?id=198971
+        <rdar://problem/51852782>
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/unit-tests/url-utilities.html:
+        * inspector/unit-tests/url-utilities-expected.txt:
+
 2019-06-18  Saam Barati  <sbar...@apple.com>
 
         [WHLSL] Do not generate duplicate constructors/copy constructors in synthesizeConstructors

Modified: trunk/LayoutTests/inspector/unit-tests/url-utilities-expected.txt (246558 => 246559)


--- trunk/LayoutTests/inspector/unit-tests/url-utilities-expected.txt	2019-06-18 19:33:41 UTC (rev 246558)
+++ trunk/LayoutTests/inspector/unit-tests/url-utilities-expected.txt	2019-06-18 19:37:35 UTC (rev 246559)
@@ -335,6 +335,22 @@
 PASS: base64 should be: 'true'
 PASS: data should be: 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
 
+-- Running test case: parseQueryString
+PASS: The query 'a' was parsed successfully.
+PASS: The query 'a&b' was parsed successfully.
+PASS: The query 'a=' was parsed successfully.
+PASS: The query 'a=&b=' was parsed successfully.
+PASS: The query 'a=1' was parsed successfully.
+PASS: The query 'a=1&b=2' was parsed successfully.
+PASS: The query 'a==1' was parsed successfully.
+PASS: The query 'a==1&b==2' was parsed successfully.
+PASS: The query 'a=1=' was parsed successfully.
+PASS: The query 'a=1=&b=2=' was parsed successfully.
+PASS: The query 'a==1=' was parsed successfully.
+PASS: The query 'a==1=&b==2=' was parsed successfully.
+PASS: The query 'a&b=1&c==2=&d&e=3&f==4=' was parsed successfully.
+PASS: The query 'a=foo%20bar&b=123%3A456' was parsed successfully.
+
 -- Running test case: WI.h2Authority
 PASS: HTTP/2 :authority of 'http://example.com' should be 'example.com'.
 PASS: HTTP/2 :authority of 'https://example.com' should be 'example.com'.

Modified: trunk/LayoutTests/inspector/unit-tests/url-utilities.html (246558 => 246559)


--- trunk/LayoutTests/inspector/unit-tests/url-utilities.html	2019-06-18 19:33:41 UTC (rev 246558)
+++ trunk/LayoutTests/inspector/unit-tests/url-utilities.html	2019-06-18 19:37:35 UTC (rev 246559)
@@ -386,6 +386,39 @@
     });
 
     suite.addTestCase({
+        name: "parseQueryString",
+        test() {
+            function test(queryString, expected) {
+                InspectorTest.expectShallowEqual(parseQueryString(queryString), expected, `The query '${queryString}' was parsed successfully.`);
+            }
+
+            test("a", {a: ""});
+            test("a&b", {a: "", b: ""});
+
+            test("a=", {a: ""});
+            test("a=&b=", {a: "", b: ""});
+
+            test("a=1", {a: "1"});
+            test("a=1&b=2", {a: "1", b: "2"});
+
+            test("a==1", {a: "=1"});
+            test("a==1&b==2", {a: "=1", b: "=2"});
+
+            test("a=1=", {a: "1="});
+            test("a=1=&b=2=", {a: "1=", b: "2="});
+
+            test("a==1=", {a: "=1="});
+            test("a==1=&b==2=", {a: "=1=", b: "=2="});
+
+            test("a&b=1&c==2=&d&e=3&f==4=", {a: "", b: "1", c: "=2=", d: "", e: "3", f: "=4="});
+
+            test("a=foo%20bar&b=123%3A456", {a: "foo bar", b: "123:456"});
+
+            return true;
+        }
+    });
+
+    suite.addTestCase({
         name: "WI.h2Authority",
         test() {
             function test(url, expected) {

Modified: trunk/Source/WebInspectorUI/ChangeLog (246558 => 246559)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-06-18 19:33:41 UTC (rev 246558)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-06-18 19:37:35 UTC (rev 246559)
@@ -1,5 +1,16 @@
 2019-06-18  Devin Rousso  <drou...@apple.com>
 
+        Web Inspector: parseQueryParameters fails to successfully parse query parameter values that contain "="
+        https://bugs.webkit.org/show_bug.cgi?id=198971
+        <rdar://problem/51852782>
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Base/URLUtilities.js:
+        (parseQueryString):
+
+2019-06-18  Devin Rousso  <drou...@apple.com>
+
         Web Inspector: REGRESSION: Heap: subsequent snapshots taken manually don't appear in the list
         https://bugs.webkit.org/show_bug.cgi?id=198941
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js (246558 => 246559)


--- trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js	2019-06-18 19:33:41 UTC (rev 246558)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js	2019-06-18 19:37:35 UTC (rev 246559)
@@ -202,13 +202,18 @@
     }
 
     var parameters = arrayResult ? [] : {};
-    var parameterStrings = queryString.split("&");
-    for (var i = 0; i < parameterStrings.length; ++i) {
-        var pair = parameterStrings[i].split("=").map(decode);
+    for (let parameterString of queryString.split("&")) {
+        let index = parameterString.indexOf("=");
+        if (index === -1)
+            index = parameterString.length;
+
+        let name = decode(parameterString.substring(0, index));
+        let value = decode(parameterString.substring(index + 1));
+
         if (arrayResult)
-            parameters.push({name: pair[0], value: pair[1]});
+            parameters.push({name, value});
         else
-            parameters[pair[0]] = pair[1];
+            parameters[name] = value;
     }
 
     return parameters;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to