Open Bug 760029 Opened 12 years ago Updated 2 years ago

XPath expression `//node()` shouldn’t match the DOCTYPE node

Categories

(Core :: XSLT, defect)

x86
macOS
defect

Tracking

()

People

(Reporter: mathias, Unassigned)

References

()

Details

As the DOCTYPE declaration is not acknowledged in the XPath/XSLT data model, XPath expressions such as `//node()` shouldn’t match the DOCTYPE node. Test case: https://bug-87888-attachments.webkit.org/attachment.cgi?id=144929 data:text/html,<!DOCTYPE%20html><script>document.write(document.evaluate('%2F%2Fnode()'%2C%20document%2C%20null%2C%20XPathResult.FIRST_ORDERED_NODE_TYPE%2C%20null).singleNodeValue%20%3D%3D%20document.documentElement%20%3F%20'PASS'%20%3A%20'FAIL')<%2Fscript>
This is probably due to a misinterpretation of http://www.w3.org/TR/xpath/#NT-NodeType, which says: > A node test `node()` is true for any node of any type whatsoever. This should have said: > A node test `node()` is true for any node of any XPath-defined node type whatsoever. This is clear when you look at the production right below it in the spec, which only mentions the specified node types: > [7] NodeTest ::= NameTest > | NodeType '(' ')' > | 'processing-instruction' '(' Literal ')' Where `NodeTest` is defined as: > [38] NodeType ::= 'comment' > | 'text' > | 'processing-instruction' > | 'node' Document type nodes are neither of those four options.
This should probably be fixed by filtering in txXPathTreeWalker::moveToFirstChild, txXPathTreeWalker::moveToLastChild and txXPathTreeWalker::moveToSibling. Additionally we should assert in txXPathNativeNode::createXPathNode.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.