Bug 30969 - A no-prefix XPath node test should not match no-namespace elements in HTML document
Summary: A no-prefix XPath node test should not match no-namespace elements in HTML do...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Minor
Assignee: Alexey Proskuryakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-30 16:18 PDT by Alexey Proskuryakov
Modified: 2009-11-02 10:42 PST (History)
1 user (show)

See Also:


Attachments
proposed patch (4.94 KB, patch)
2009-10-30 16:22 PDT, Alexey Proskuryakov
darin: review+
ap: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2009-10-30 16:18:09 PDT
Because it matches elements in the default XHTML namespace, and XHTML now says that this should change, see <http://www.w3.org/Bugs/Public/show_bug.cgi?id=7059>.
Comment 1 Alexey Proskuryakov 2009-10-30 16:22:22 PDT
Created attachment 42243 [details]
proposed patch
Comment 2 Darin Adler 2009-10-30 16:26:26 PDT
Comment on attachment 42243 [details]
proposed patch

> -            if (node->isHTMLElement() && node->document()->isHTMLDocument()) {
> -                // Paths without namespaces should match HTML elements in HTML documents despite those having an XHTML namespace. Names are compared case-insensitively.
> -                return equalIgnoringCase(static_cast<Element*>(node)->localName(), name) && (namespaceURI.isNull() || namespaceURI == node->namespaceURI());
> +            if (node->document()->isHTMLDocument()) {
> +                if (node->isHTMLElement()) {
> +                    // Paths without namespaces should match HTML elements in HTML documents despite those having an XHTML namespace. Names are compared case-insensitively.
> +                    return equalIgnoringCase(static_cast<Element*>(node)->localName(), name) && (namespaceURI.isNull() || namespaceURI == node->namespaceURI());
> +                } else {
> +                    // An expression without any prefix shouldn't match no-namespace nodes (because HTML5 says so).
> +                    return static_cast<Element*>(node)->hasLocalName(name) && namespaceURI == node->namespaceURI() && !namespaceURI.isNull();
> +                }

We normally don't do else after return.

It would be nice if the test case covered a few more cases than just the bug-fixed one.

r=me
Comment 3 Alexey Proskuryakov 2009-10-30 16:30:11 PDT
> It would be nice if the test case covered a few more cases than just the
> bug-fixed one.

We've got a number of tests for namespaces in XPath element node tests - these few lines of code have a long history.
Comment 4 Alexey Proskuryakov 2009-11-02 10:42:39 PST
Committed <http://trac.webkit.org/changeset/50419>.