Bug 15989 - XPath queries with predicates incorrectly retains the current node across unions
Summary: XPath queries with predicates incorrectly retains the current node across unions
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-14 12:41 PST by Khoo Yit Phang
Modified: 2007-11-15 22:04 PST (History)
1 user (show)

See Also:


Attachments
Test case in XHTML and inline Javascript. (2.53 KB, application/xhtml+xml)
2007-11-14 12:42 PST, Khoo Yit Phang
no flags Details
proposed fix (8.25 KB, patch)
2007-11-15 12:28 PST, Alexey Proskuryakov
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Khoo Yit Phang 2007-11-14 12:41:07 PST
In the nightlies as well as Safari 3.0.3 on Tiger, XPath queries which contain unions of queries with predicates (e.g. "ancestor::xhtml:*[local-name()='span']|.") doesn't quite work right. It seems that the context-node gets overwritten by each union operand predicate, so every subsequent operand is applied to the wrong context node.

E.g.:

<div>
    <span id="A">
        <span id="B"/>
    </span>
</div>

The query "ancestor::xhtml:*[local-name()='span']|." from span#B will not return [span#A, span#B] since the context-node for both operands are span#B. It will instead return [span#A, div], as if the context-node for the second operand had been the top-most ancestor.
Comment 1 Khoo Yit Phang 2007-11-14 12:42:19 PST
Created attachment 17276 [details]
Test case in XHTML and inline Javascript.
Comment 2 Alexey Proskuryakov 2007-11-15 12:28:09 PST
Created attachment 17300 [details]
proposed fix

This makes me think that we might need to import another large XPath test suite. Unfortunately, the only ones I know are XSLT-based, and would require a lot of work to adapt.

I've tried to think of other places where we need to restore the context, but I don't see any.
Comment 3 Darin Adler 2007-11-15 13:29:41 PST
Comment on attachment 17300 [details]
proposed fix

r=me

\ No newline at end of file

Can we fix that?
Comment 4 Alexey Proskuryakov 2007-11-15 22:04:59 PST
Committed revision 27837.