summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-01-30 08:54:09 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-01-30 11:51:07 -0800
commit1ed6d2102bc0a08648026ece8cc069fda592a6a2 (patch)
tree07875e41bbfc268d17cc3389929f0b5e1f9f745b
parentbc1e444694427d599710107d3e6b62165380b0b6 (diff)
XPath: Improve error message for expressions like .[1]
W3C specification does not allow predicates after abbreviated steps. Currently this results in parsing terminating at the step, which leads to confusing error messages like "Invalid query" or "Unmatched braces".
-rw-r--r--src/pugixml.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 396061a..94bd8ae 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -11398,12 +11398,18 @@ PUGI__NS_BEGIN
{
_lexer.next();
+ if (_lexer.current() == lex_open_square_brace)
+ return error("Predicates are not allowed after an abbreviated step");
+
return alloc_node(ast_step, set, axis_self, nodetest_type_node, 0);
}
else if (_lexer.current() == lex_double_dot)
{
_lexer.next();
+ if (_lexer.current() == lex_open_square_brace)
+ return error("Predicates are not allowed after an abbreviated step");
+
return alloc_node(ast_step, set, axis_parent, nodetest_type_node, 0);
}