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
@ -5949,7 +5949,28 @@ namespace pugi
|
|||||||
|
|
||||||
case '$':
|
case '$':
|
||||||
cur += 1;
|
cur += 1;
|
||||||
|
|
||||||
|
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;
|
_cur_lexeme = lex_var_ref;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_cur_lexeme = lex_none;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -6124,7 +6145,7 @@ namespace pugi
|
|||||||
|
|
||||||
const xpath_lexer_string& contents() const
|
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;
|
return _cur_lexeme_contents;
|
||||||
}
|
}
|
||||||
@ -7738,16 +7759,11 @@ namespace pugi
|
|||||||
{
|
{
|
||||||
case lex_var_ref:
|
case lex_var_ref:
|
||||||
{
|
{
|
||||||
_lexer.next();
|
xpath_lexer_string name = _lexer.contents();
|
||||||
|
|
||||||
if (_lexer.current() != lex_string)
|
|
||||||
throw_error("Variable name expected");
|
|
||||||
|
|
||||||
if (!_variables)
|
if (!_variables)
|
||||||
throw_error("Unknown variable: variable set is not provided");
|
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);
|
xpath_variable* var = get_variable(_variables, name.begin, name.end);
|
||||||
|
|
||||||
if (!var)
|
if (!var)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user