Title: [183612] trunk
Revision
183612
Author
[email protected]
Date
2015-04-29 20:27:34 -0700 (Wed, 29 Apr 2015)

Log Message

LiveNodeList may unexpectedly return an element for empty string
https://bugs.webkit.org/show_bug.cgi?id=144429

Reviewed by Darin Adler.

Source/WebCore:

* dom/LiveNodeList.cpp:
(WebCore::LiveNodeList::namedItem):
Never return a result for an empty string.

LayoutTests:

* fast/dom/named-items-with-empty-name-expected.txt:
* fast/dom/named-items-with-empty-name.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (183611 => 183612)


--- trunk/LayoutTests/ChangeLog	2015-04-30 03:21:27 UTC (rev 183611)
+++ trunk/LayoutTests/ChangeLog	2015-04-30 03:27:34 UTC (rev 183612)
@@ -1,3 +1,13 @@
+2015-04-29  Joseph Pecoraro  <[email protected]>
+
+        LiveNodeList may unexpectedly return an element for empty string
+        https://bugs.webkit.org/show_bug.cgi?id=144429
+
+        Reviewed by Darin Adler.
+
+        * fast/dom/named-items-with-empty-name-expected.txt:
+        * fast/dom/named-items-with-empty-name.html:
+
 2015-04-29  Dean Jackson  <[email protected]>
 
         Create a named CSS property for system colors

Modified: trunk/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt (183611 => 183612)


--- trunk/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt	2015-04-30 03:21:27 UTC (rev 183611)
+++ trunk/LayoutTests/fast/dom/named-items-with-empty-name-expected.txt	2015-04-30 03:27:34 UTC (rev 183612)
@@ -7,4 +7,7 @@
 PASS document.getElementsByTagName('div')[''] === undefined is true
 PASS document.body.children[''] === undefined is true
 PASS document.all[''] === undefined is true
+PASS container.querySelectorAll('div')[''] === undefined is true
+PASS container.getElementsByTagName('div')[''] === undefined is true
+PASS container.children[''] === undefined is true
 

Modified: trunk/LayoutTests/fast/dom/named-items-with-empty-name.html (183611 => 183612)


--- trunk/LayoutTests/fast/dom/named-items-with-empty-name.html	2015-04-30 03:21:27 UTC (rev 183611)
+++ trunk/LayoutTests/fast/dom/named-items-with-empty-name.html	2015-04-30 03:27:34 UTC (rev 183612)
@@ -14,6 +14,15 @@
 shouldBeTrue("document.getElementsByTagName('div')[''] === undefined");
 shouldBeTrue("document.body.children[''] === undefined");
 shouldBeTrue("document.all[''] === undefined");
+
+// Collections not in the document.
+var container = document.createElement("div");
+var div = document.createElement("div");
+div.id = "";
+container.appendChild(div);
+shouldBeTrue("container.querySelectorAll('div')[''] === undefined");
+shouldBeTrue("container.getElementsByTagName('div')[''] === undefined");
+shouldBeTrue("container.children[''] === undefined");
 </script>
 <script src=""
 </body>

Modified: trunk/Source/WebCore/ChangeLog (183611 => 183612)


--- trunk/Source/WebCore/ChangeLog	2015-04-30 03:21:27 UTC (rev 183611)
+++ trunk/Source/WebCore/ChangeLog	2015-04-30 03:27:34 UTC (rev 183612)
@@ -1,3 +1,14 @@
+2015-04-29  Joseph Pecoraro  <[email protected]>
+
+        LiveNodeList may unexpectedly return an element for empty string
+        https://bugs.webkit.org/show_bug.cgi?id=144429
+
+        Reviewed by Darin Adler.
+
+        * dom/LiveNodeList.cpp:
+        (WebCore::LiveNodeList::namedItem):
+        Never return a result for an empty string.
+
 2015-04-29  Gyuyoung Kim  <[email protected]>
 
         Remove PassRefPtr in SVGFEFooElement classes

Modified: trunk/Source/WebCore/dom/LiveNodeList.cpp (183611 => 183612)


--- trunk/Source/WebCore/dom/LiveNodeList.cpp	2015-04-30 03:21:27 UTC (rev 183611)
+++ trunk/Source/WebCore/dom/LiveNodeList.cpp	2015-04-30 03:27:34 UTC (rev 183612)
@@ -65,6 +65,9 @@
         // In the case of multiple nodes with the same name, just fall through.
     }
 
+    if (elementId.isEmpty())
+        return nullptr;
+
     unsigned length = this->length();
     for (unsigned i = 0; i < length; i++) {
         Node* node = item(i);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to