Closed
Bug 277777
(XPath-FCP)
Opened 20 years ago
Closed 20 years ago
Unevaluated XPath 2.0 expressions throwing errors
Categories
(Core :: XSLT, defect)
Tracking
()
VERIFIED
FIXED
People
(Reporter: bugzilla, Assigned: sicking)
Details
(Keywords: testcase)
Attachments
(3 files, 3 obsolete files)
|
721 bytes,
text/xml
|
Details | |
|
154 bytes,
text/xml
|
Details | |
|
12.87 KB,
patch
|
axel
:
review+
peterv
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
XSLT 1.0 processors handling an XSLT 2.0 must not raise an error on unevaluated
XPath expressions. Mozilla and family should not be halting on code like:
<xsl:when test="system-property('xsl:version') >= 2">
<xsl:if test="some $x in ./* satisfies local-name(.)='bar'">
<p>bar exists</p>
</xsl:if>
</xsl:when>
because the XPath 2.0 expression is wrapped such that Mozilla's XSLT 1.0
processor can never evaluate it.
According to the XSLT spec, section 2.5:
If an expression occurs in an attribute that is processed in
forwards-compatible mode, then an XSLT processor must recover
from errors in the expression as follows:
* if the expression does not match the syntax allowed by the
XPath grammar, then an error must not be signaled unless the
expression is actually evaluated;
Reproducible: Always
Steps to Reproduce:
Comment 1•20 years ago
|
||
I'd like to see a testcase for this. See http://www.mozilla.org/projects/xslt/bug-reporting.html, Creating testcases.
| Reporter | ||
Comment 2•20 years ago
|
||
| Reporter | ||
Comment 3•20 years ago
|
||
Here's your test case.
Comment 4•20 years ago
|
||
http://lxr.mozilla.org/seamonkey/source/extensions/transformiix/source/xslt/txStylesheetCompileHandlers.cpp#194 is the culprit. We require that the expr is both optional and that it is in fcp. Jonas is our god of reading the fcp parts of the spec (and it is his code, too), I wonder what he thinks.
| Assignee | ||
Comment 5•20 years ago
|
||
Ugh, it indeed seems like we're doing the wrong thing here. We're not supporting forwards compatible parsing of expressions well at all. Apparently I only did fcp of elements, not of expressions.
| Assignee | ||
Comment 6•20 years ago
|
||
What we should do is to create an ErrorExpr that always throws an error (or just use txErrorFunctionCall). Then make getExprAttr and getAVTAttr return an instance of this when the parsing fails and fcp is enabled. Additionally we should set fnCall to a new txErrorFunctionCall at http://lxr.mozilla.org/mozilla/source/extensions/transformiix/source/xpath/ExprParser.cpp#553 when fcp is enabled. Both these things could be done always rather then when fcp is enabled if we wanted to.
| Assignee | ||
Comment 7•20 years ago
|
||
Note that the current check in getAVTAttr and getExprAttr is correct. It is implementing the third bullet in the first list in section 2.5. An additional check is needed though to implement the first bullet in the second list.
| Assignee | ||
Comment 8•20 years ago
|
||
Err, the change shouldn't be made in ExprParser since that'll make it impossible for extensions (like xslt) to implement extensions in the null namespace. But we should rather add code to txStylesheetCompilerState::resolveFunctionCall. That will also make it trivial to only do it in fcp mode.
| Assignee | ||
Comment 9•20 years ago
|
||
Pike pointed out that we already take care of unrecongized functions. So all that's needed is the first paragraph of comment 6. Though I wonder if we handle unrecongized functions in a good way. The current solution makes us parse bad functions in DOM-XPath, though they'll fail when evaluated. Either we could push the txErrorFunctionCall creation to the resolveFunctionCall implementors, or we could add an inFCP() function to txIParseContext and only create the txErrorFunctionCall then. I think I like the latter better.
| Reporter | ||
Updated•20 years ago
|
Alias: XPath-FCP
| Assignee | ||
Comment 11•20 years ago
|
||
Attachment #171765 -
Flags: superreview?(peterv)
Attachment #171765 -
Flags: review?(axel)
| Assignee | ||
Comment 12•20 years ago
|
||
crap! my editor took it upon itself to do some whitespace cleanup. I won't check the ws only stuff in.
| Reporter | ||
Comment 13•20 years ago
|
||
Correct logic of XPath 2.0 expression, though this doesn't affect demonstration of bug.
Attachment #170825 -
Attachment is obsolete: true
| Reporter | ||
Comment 14•20 years ago
|
||
Changed URL on stylesheet to revised stylesheet attachment.
Attachment #170826 -
Attachment is obsolete: true
| Assignee | ||
Comment 15•20 years ago
|
||
without whitespace 'cleanup's. Same otherwise
Attachment #171765 -
Attachment is obsolete: true
Attachment #171821 -
Flags: superreview?(peterv)
Attachment #171821 -
Flags: review?(axel)
| Assignee | ||
Updated•20 years ago
|
Attachment #171765 -
Flags: superreview?(peterv)
Attachment #171765 -
Flags: review?(axel)
Comment 16•20 years ago
|
||
Comment on attachment 171821 [details] [diff] [review] patch to fix v1.1 >Index: source/xslt/txStylesheetCompileHandlers.cpp >=================================================================== >@@ -214,15 +224,29 @@ getAVTAttr(txStylesheetAttr* aAttributes > aName, aRequired, &attr); > if (!attr) { > return rv; > } > > aAVT = txExprParser::createAttributeValueTemplate(attr->mValue, &aState); >- if (!aAVT && (aRequired || !aState.fcp())) { >- // XXX ErrorReport: XPath parse failure >- return NS_ERROR_XPATH_PARSE_FAILURE; >+ if (!aAVT) { >+ if (aRequired) { >+ } >+ else { >+ aAVT = nsnull; You can drop this, aAVT is already null. >--- /dev/null 2005-01-20 01:48:08.375000000 +0100 >+++ source/xpath/txErrorExpr.cpp 2005-01-19 16:59:09.718750000 +0100 >+ * Portions created by the Initial Developer are Copyright (C) 2002 2005
Attachment #171821 -
Flags: superreview?(peterv) → superreview+
Updated•20 years ago
|
Attachment #171821 -
Flags: review?(axel) → review+
| Assignee | ||
Comment 17•20 years ago
|
||
check in, thanks for reviews
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 18•20 years ago
|
||
Robin: please mark this bug verified if things now work as they should.
| Reporter | ||
Comment 19•20 years ago
|
||
Works now in Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b) Gecko/20050125. Marking verified.
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•