Project

Profile

Help

Bug #2715

closed

XPath parsing edge cases

Added by Michael Kay about 8 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Sprint/Milestone:
Start date:
2016-04-19
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7, trunk
Fix Committed on Branch:
9.7, trunk
Fixed in Maintenance Release:
Platforms:

Description

See https://lists.w3.org/Archives/Public/public-xsl-query/2016Mar/0037.html

The WG believes that the XPath grammar allows expressions such as

12!(12 div.)

 12 div-3

 3!(12 div-.)

which Saxon cannot parse. The key point is that Saxon is reading the "." or "-" as a continuation of the token starting "div", which it should not do, because the tokenization rule is to accept the longest token consistent with the grammar, and in these contexts, an NCName containing a "." or "-" is not consistent with the grammar.

Actions #1

Updated by Michael Kay about 8 years ago

  • Status changed from New to Resolved
  • Applies to branch 9.7, 9.8 added
  • Fix Committed on Branch 9.7, 9.8 added

I've tweaked the tokenizer to handle these cases, though the solution might not be completely general. Essentially the fix is as follows:

if we encounter "." or "-" when reading (what appears to be) a name, then we check whether the following conditions are true:

(a) the content of the token so far is a valid operator/keyword

(b) the preceding token is not classified as an operator symbol (token number > LAST_OPERATOR) and is not "?" or "*:"

(c) the preceding token is not a name that is equal to a valid operator/keyword

if all these conditions are true then we stop the tokenizing at the "." or "-" and return the operator token.

Condition (c) was found to be necessary because when we are parsing a FLWOR expression, keywords such as "in" and "return" are returned as NAME tokens rather than as specific operator tokens.

I'm committing a patch on the 9.7 and 9.8 branches.

Actions #2

Updated by O'Neil Delpratt almost 8 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 9.7.0.5 added

Bug fix applied in the Saxon 9.7.0.5 maintenance release.

Actions #3

Updated by O'Neil Delpratt almost 8 years ago

  • Sprint/Milestone set to 9.7.0.5
Actions #4

Updated by O'Neil Delpratt almost 7 years ago

  • Applies to branch trunk added
  • Applies to branch deleted (9.8)
Actions #5

Updated by O'Neil Delpratt almost 7 years ago

  • Fix Committed on Branch trunk added
  • Fix Committed on Branch deleted (9.8)

Please register to edit this issue

Also available in: Atom PDF