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
This commit is contained in:
parent
61ceb10baf
commit
59e034149f
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user