WindowFeatures arguments shoud ignore invalid characters in values
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jun 2014 22:41:03 +0000 (22:41 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Jun 2014 22:41:03 +0000 (22:41 +0000)
<http://webkit.org/b/133703>
<rdar://problem/17254118>

Reviewed by Andy Estes.

Source/WebCore:

Test: fast/dom/Window/window-property-invalid-characters-ignored.html

* page/WindowFeatures.cpp:
(WebCore::WindowFeatures::WindowFeatures): Set |length| based on
|buffer|, not |features|.  Switch to using a for loop.  Switch
to unsigned types since we are working with positive offsets
into a String.

LayoutTests:

* fast/dom/Window/resources/window-property-invalid-characters-ignored.html: Added.
* fast/dom/Window/window-property-invalid-characters-ignored-expected.txt: Added.
* fast/dom/Window/window-property-invalid-characters-ignored.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/Window/resources/window-property-invalid-characters-ignored.html [new file with mode: 0644]
LayoutTests/fast/dom/Window/window-property-invalid-characters-ignored-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/Window/window-property-invalid-characters-ignored.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/WindowFeatures.cpp

index 1ee18b81d524bbed9f4ec555cc86a2f3a1adedd1..6a44f51bff52a7a1b481947470345a298d35cdbe 100644 (file)
@@ -1,3 +1,15 @@
+2014-06-11  David Kilzer  <ddkilzer@apple.com>
+
+        WindowFeatures arguments shoud ignore invalid characters in values
+        <http://webkit.org/b/133703>
+        <rdar://problem/17254118>
+
+        Reviewed by Andy Estes.
+
+        * fast/dom/Window/resources/window-property-invalid-characters-ignored.html: Added.
+        * fast/dom/Window/window-property-invalid-characters-ignored-expected.txt: Added.
+        * fast/dom/Window/window-property-invalid-characters-ignored.html: Added.
+
 2014-06-11  David Kilzer  <ddkilzer@apple.com>
 
         Viewport arguments should ignore invalid characters in values
diff --git a/LayoutTests/fast/dom/Window/resources/window-property-invalid-characters-ignored.html b/LayoutTests/fast/dom/Window/resources/window-property-invalid-characters-ignored.html
new file mode 100644 (file)
index 0000000..503f352
--- /dev/null
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<html><head></head><body onload="setTimeout('window.opener.finishTest()', 0)"></body></html>
diff --git a/LayoutTests/fast/dom/Window/window-property-invalid-characters-ignored-expected.txt b/LayoutTests/fast/dom/Window/window-property-invalid-characters-ignored-expected.txt
new file mode 100644 (file)
index 0000000..52636e6
--- /dev/null
@@ -0,0 +1,12 @@
+Tests that invalid characters are ignored after a window property value.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS w.document.width is 123
+PASS w.document.height is 123
+PASS w !== window is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/Window/window-property-invalid-characters-ignored.html b/LayoutTests/fast/dom/Window/window-property-invalid-characters-ignored.html
new file mode 100644 (file)
index 0000000..6f28602
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<script>
+jsTestIsAsync = true;
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.setCanOpenWindows();
+}
+
+description("Tests that invalid characters are ignored after a window property value.");
+
+var w = window.open("resources/window-property-invalid-characters-ignored.html", "blank", "width=123\u0130,height=123\u0130");
+
+function finishTest()
+{
+    shouldBe("w.document.width", "123");
+    shouldBe("w.document.height", "123");
+    shouldBeTrue("w !== window");
+    w.close();
+
+    finishJSTest();
+}
+
+successfullyParsed = true;
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+</head>
+<body>
+<pre id="console"></pre>
+</body>
+</html>
index 3eef780e550463bbf25b29bae76331521833ab42..6b9547f216b7188b048f8dc2badc7e39ab7612f2 100644 (file)
@@ -1,3 +1,19 @@
+2014-06-11  David Kilzer  <ddkilzer@apple.com>
+
+        WindowFeatures arguments shoud ignore invalid characters in values
+        <http://webkit.org/b/133703>
+        <rdar://problem/17254118>
+
+        Reviewed by Andy Estes.
+
+        Test: fast/dom/Window/window-property-invalid-characters-ignored.html
+
+        * page/WindowFeatures.cpp:
+        (WebCore::WindowFeatures::WindowFeatures): Set |length| based on
+        |buffer|, not |features|.  Switch to using a for loop.  Switch
+        to unsigned types since we are working with positive offsets
+        into a String.
+
 2014-06-11  David Kilzer  <ddkilzer@apple.com>
 
         Viewport arguments should ignore invalid characters in values
index 0517bdb4a5de03a1eaf21ef05c3120912e817199..0829887446f15a1efefb2e79840e8bc952ed1c2c 100644 (file)
@@ -74,13 +74,12 @@ WindowFeatures::WindowFeatures(const String& features)
     scrollbarsVisible = false;
 
     // Tread lightly in this code -- it was specifically designed to mimic Win IE's parsing behavior.
-    int keyBegin, keyEnd;
-    int valueBegin, valueEnd;
+    unsigned keyBegin, keyEnd;
+    unsigned valueBegin, valueEnd;
 
-    int i = 0;
-    int length = features.length();
     String buffer = features.lower();
-    while (i < length) {
+    unsigned length = buffer.length();
+    for (unsigned i = 0; i < length; ) {
         // skip to first non-separator, but don't skip past the end of the string
         while (isWindowFeaturesSeparator(buffer[i])) {
             if (i >= length)