[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
ap at apple.com
ap at apple.com
Wed Jan 20 22:26:42 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 1dfee0d1608c4a4ea2977542e7f7bd856e7a4485
Author: ap at apple.com <ap at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Jan 16 20:53:12 2010 +0000
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=33752
Assertion failure when getting a href attribute with prefix
This was due to a temporary change made in 2005 (r9639) - checks in checkSetPrefix were
disabled during introduction of QualifiedName, but never re-enabled.
Tests: fast/dom/bad-href-attribute.html
fast/dom/node-prefix-setter-namespace-exception.html
* dom/Attr.cpp: (WebCore::Attr::setPrefix):
* dom/Element.cpp: (WebCore::Element::setPrefix):
* dom/Node.cpp: (WebCore::Node::checkSetPrefix):
Re-enabled the checks. Also, changed the prefix setter to treat "" as null, matching Firefox
(DOM 3 Core spec says this behavior is implementation defined).
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53363 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 26d7f3a..42c7186 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-01-15 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Darin Adler.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33752
+ Assertion failure when getting a href attribute with prefix
+
+ * fast/dom/bad-href-attribute-expected.txt: Added.
+ * fast/dom/bad-href-attribute.html: Added.
+ * fast/dom/node-prefix-setter-namespace-exception-expected.txt: Added.
+ * fast/dom/node-prefix-setter-namespace-exception.html: Added.
+ * fast/dom/script-tests/node-prefix-setter-namespace-exception.js: Added.
+
2010-01-16 Brady Eidson <beidson at apple.com>
Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/dom/bad-href-attribute-expected.txt b/LayoutTests/fast/dom/bad-href-attribute-expected.txt
new file mode 100644
index 0000000..373653c
--- /dev/null
+++ b/LayoutTests/fast/dom/bad-href-attribute-expected.txt
@@ -0,0 +1,6 @@
+Test that you can't set a prefix for a node with null namespace.
+
+Should say PASS:
+
+PASS
+
diff --git a/LayoutTests/fast/dom/bad-href-attribute.html b/LayoutTests/fast/dom/bad-href-attribute.html
new file mode 100644
index 0000000..0461ef8
--- /dev/null
+++ b/LayoutTests/fast/dom/bad-href-attribute.html
@@ -0,0 +1,31 @@
+<body>
+<p>Test that you can't set a prefix for a node with null namespace.</p>
+<p>Should say PASS:</p>
+<pre id = log></pre>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function log(msg)
+{
+ document.getElementById("log").innerHTML += msg + "\n";
+}
+
+var a = document.createElement("a");
+var attr = document.createAttribute("href");
+attr.value = "#";
+
+try {
+ attr.prefix = "foo";
+ log("FAIL: Was able to change the prefix.");
+} catch (ex) {
+ log("PASS");
+}
+
+a.setAttributeNode(attr);
+
+// WebKit used to crash with an assertion here.
+a.href;
+
+</script>
+</body>
diff --git a/LayoutTests/fast/dom/node-prefix-setter-namespace-exception-expected.txt b/LayoutTests/fast/dom/node-prefix-setter-namespace-exception-expected.txt
new file mode 100644
index 0000000..2de759e
--- /dev/null
+++ b/LayoutTests/fast/dom/node-prefix-setter-namespace-exception-expected.txt
@@ -0,0 +1,18 @@
+Test how Node.prefix setter raises NAMESPACE_ERR.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS href.prefix is null
+PASS document.createAttribute('attr').prefix = 'abc' threw exception Error: NAMESPACE_ERR: DOM Exception 14.
+PASS document.createAttributeNS(null, 'attr').prefix = 'abc' threw exception Error: NAMESPACE_ERR: DOM Exception 14.
+PASS document.createElementNS(null, 'attr').prefix = 'abc' threw exception Error: NAMESPACE_ERR: DOM Exception 14.
+PASS document.createAttributeNS('foo', 'bar').prefix = 'xml' threw exception Error: NAMESPACE_ERR: DOM Exception 14.
+PASS document.createElementNS('foo', 'bar').prefix = 'xml' threw exception Error: NAMESPACE_ERR: DOM Exception 14.
+PASS document.createAttribute('attr').prefix = 'xmlns' threw exception Error: NAMESPACE_ERR: DOM Exception 14.
+PASS document.createAttributeNS('foo', 'attr').prefix = 'xmlns' threw exception Error: NAMESPACE_ERR: DOM Exception 14.
+PASS document.createAttribute('xmlns').prefix = 'foo' threw exception Error: NAMESPACE_ERR: DOM Exception 14.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/dom/node-prefix-setter-namespace-exception.html b/LayoutTests/fast/dom/node-prefix-setter-namespace-exception.html
new file mode 100644
index 0000000..9f8af87
--- /dev/null
+++ b/LayoutTests/fast/dom/node-prefix-setter-namespace-exception.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/node-prefix-setter-namespace-exception.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/script-tests/node-prefix-setter-namespace-exception.js b/LayoutTests/fast/dom/script-tests/node-prefix-setter-namespace-exception.js
new file mode 100644
index 0000000..33b97e3
--- /dev/null
+++ b/LayoutTests/fast/dom/script-tests/node-prefix-setter-namespace-exception.js
@@ -0,0 +1,25 @@
+description("Test how Node.prefix setter raises NAMESPACE_ERR.");
+
+var href = document.createAttribute("href");
+href.value = "#";
+
+// Should not throw.
+href.prefix = null;
+
+// Per DOM3 Core spec, setting to empty is implementation dependent.
+// Firefox treats empty like null.
+href.prefix = "";
+shouldBe("href.prefix", "null");
+
+shouldThrow("document.createAttribute('attr').prefix = 'abc'");
+shouldThrow("document.createAttributeNS(null, 'attr').prefix = 'abc'");
+shouldThrow("document.createElementNS(null, 'attr').prefix = 'abc'");
+shouldThrow("document.createAttributeNS('foo', 'bar').prefix = 'xml'");
+shouldThrow("document.createElementNS('foo', 'bar').prefix = 'xml'");
+shouldThrow("document.createAttribute('attr').prefix = 'xmlns'");
+shouldThrow("document.createAttributeNS('foo', 'attr').prefix = 'xmlns'");
+shouldThrow("document.createAttribute('xmlns').prefix = 'foo'");
+
+
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5804959..55a94c9 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-01-15 Alexey Proskuryakov <ap at apple.com>
+
+ Reviewed by Darin Adler.
+
+ https://bugs.webkit.org/show_bug.cgi?id=33752
+ Assertion failure when getting a href attribute with prefix
+
+ This was due to a temporary change made in 2005 (r9639) - checks in checkSetPrefix were
+ disabled during introduction of QualifiedName, but never re-enabled.
+
+ Tests: fast/dom/bad-href-attribute.html
+ fast/dom/node-prefix-setter-namespace-exception.html
+
+ * dom/Attr.cpp: (WebCore::Attr::setPrefix):
+ * dom/Element.cpp: (WebCore::Element::setPrefix):
+ * dom/Node.cpp: (WebCore::Node::checkSetPrefix):
+ Re-enabled the checks. Also, changed the prefix setter to treat "" as null, matching Firefox
+ (DOM 3 Core spec says this behavior is implementation defined).
+
2010-01-16 Brady Eidson <beidson at apple.com>
Reviewed by Darin Adler.
diff --git a/WebCore/dom/Attr.cpp b/WebCore/dom/Attr.cpp
index 8a0b51f..a782756 100644
--- a/WebCore/dom/Attr.cpp
+++ b/WebCore/dom/Attr.cpp
@@ -102,7 +102,13 @@ void Attr::setPrefix(const AtomicString& prefix, ExceptionCode& ec)
if (ec)
return;
- m_attribute->setPrefix(prefix);
+ if ((prefix == "xmlns" && namespaceURI() != "http://www.w3.org/2000/xmlns/")
+ || static_cast<Attr*>(this)->qualifiedName() == "xmlns") {
+ ec = NAMESPACE_ERR;
+ return;
+ }
+
+ m_attribute->setPrefix(prefix.isEmpty() ? AtomicString() : prefix);
}
String Attr::nodeValue() const
diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp
index 62f8d4c..a7e017f 100644
--- a/WebCore/dom/Element.cpp
+++ b/WebCore/dom/Element.cpp
@@ -669,14 +669,14 @@ String Element::nodeNamePreservingCase() const
return m_tagName.toString();
}
-void Element::setPrefix(const AtomicString &_prefix, ExceptionCode& ec)
+void Element::setPrefix(const AtomicString& prefix, ExceptionCode& ec)
{
ec = 0;
- checkSetPrefix(_prefix, ec);
+ checkSetPrefix(prefix, ec);
if (ec)
return;
- m_tagName.setPrefix(_prefix);
+ m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix);
}
KURL Element::baseURI() const
diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp
index 70485cc..4a47dbc 100644
--- a/WebCore/dom/Node.cpp
+++ b/WebCore/dom/Node.cpp
@@ -1040,34 +1040,27 @@ Node* Node::traversePreviousSiblingPostOrder(const Node* stayWithin) const
return 0;
}
-void Node::checkSetPrefix(const AtomicString&, ExceptionCode& ec)
+void Node::checkSetPrefix(const AtomicString& prefix, ExceptionCode& ec)
{
// Perform error checking as required by spec for setting Node.prefix. Used by
// Element::setPrefix() and Attr::setPrefix()
// FIXME: Implement support for INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character.
- // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
if (isReadOnlyNode()) {
ec = NO_MODIFICATION_ALLOWED_ERR;
return;
}
- // FIXME: Implement NAMESPACE_ERR: - Raised if the specified prefix is malformed
- // We have to comment this out, since it's used for attributes and tag names, and we've only
- // switched one over.
- /*
- // - if the namespaceURI of this node is null,
- // - if the specified prefix is "xml" and the namespaceURI of this node is different from
- // "http://www.w3.org/XML/1998/namespace",
- // - if this node is an attribute and the specified prefix is "xmlns" and
- // the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/",
- // - or if this node is an attribute and the qualifiedName of this node is "xmlns" [Namespaces].
- if ((namespacePart(id()) == noNamespace && id() > ID_LAST_TAG) ||
- (_prefix == "xml" && String(document()->namespaceURI(id())) != "http://www.w3.org/XML/1998/namespace")) {
+ // FIXME: Raise NAMESPACE_ERR if prefix is malformed per the Namespaces in XML specification.
+
+ const AtomicString& nodeNamespaceURI = namespaceURI();
+ if ((nodeNamespaceURI.isEmpty() && !prefix.isEmpty())
+ || (prefix == "xml" && nodeNamespaceURI != XMLNames::xmlNamespaceURI)) {
ec = NAMESPACE_ERR;
return;
- }*/
+ }
+ // Attribute-specific checks are in Attr::setPrefix().
}
bool Node::canReplaceChild(Node* newChild, Node*)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list