summaryrefslogtreecommitdiff
path: root/src/pugixml.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:40:38 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:40:38 +0000
commit59e034149fd3fd95c14a19e4e5588f4861131cbb (patch)
tree6c43a5596eaf9669572082836429dbd7691347d5 /src/pugixml.cpp
parent61ceb10baf347bb19078afdb945a6cdec85777d7 (diff)
XPath: Reworked variable reference parsing, '$ name' and '$foo:*' are now correctly rejected
git-svn-id: http://pugixml.googlecode.com/svn/trunk@682 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r--src/pugixml.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp
index 1a69a8e..7981d16 100644
--- a/src/pugixml.cpp
+++ b/src/pugixml.cpp
@@ -5946,13 +5946,34 @@ namespace pugi
_cur_lexeme = lex_union;
break;
-
+
case '$':
cur += 1;
- _cur_lexeme = lex_var_ref;
+
+ if (IS_CHARTYPEX(*cur, ctx_start_symbol))
+ {
+ _cur_lexeme_contents.begin = cur;
+
+ while (IS_CHARTYPEX(*cur, ctx_symbol)) cur++;
+
+ if (cur[0] == ':' && IS_CHARTYPEX(cur[1], ctx_symbol)) // qname
+ {
+ cur++; // :
+
+ while (IS_CHARTYPEX(*cur, ctx_symbol)) cur++;
+ }
+
+ _cur_lexeme_contents.end = cur;
+
+ _cur_lexeme = lex_var_ref;
+ }
+ else
+ {
+ _cur_lexeme = lex_none;
+ }
break;
-
+
case '(':
cur += 1;
_cur_lexeme = lex_open_brace;
@@ -6124,7 +6145,7 @@ namespace pugi
const xpath_lexer_string& contents() const
{
- assert(_cur_lexeme == lex_number || _cur_lexeme == lex_string || _cur_lexeme == lex_quoted_string);
+ assert(_cur_lexeme == lex_var_ref || _cur_lexeme == lex_number || _cur_lexeme == lex_string || _cur_lexeme == lex_quoted_string);
return _cur_lexeme_contents;
}
@@ -7738,16 +7759,11 @@ namespace pugi
{
case lex_var_ref:
{
- _lexer.next();
-
- if (_lexer.current() != lex_string)
- throw_error("Variable name expected");
+ xpath_lexer_string name = _lexer.contents();
if (!_variables)
throw_error("Unknown variable: variable set is not provided");
- xpath_lexer_string name = _lexer.contents();
-
xpath_variable* var = get_variable(_variables, name.begin, name.end);
if (!var)