Mercurial > hg
changeset 23994:8a2156780839
revset: replace parsing alias definition by _parsealiasdefn to parse strictly
Before this patch, referring alias arguments is parsed by string base
operation "str.replace".
This causes problems below (see the previous patch introducing
"_parsealiasdefn" for detail)
- the shorter name argument breaks referring the longer name
- argument names in the quoted string are broken
This patch replaces parsing alias definition by "_parsealiasdefn" to
parse strictly.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 02 Feb 2015 23:07:04 +0900 |
parents | eedade006458 |
children | d8330fb8c44d |
files | mercurial/revset.py tests/test-revset.t |
diffstat | 2 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Mon Feb 02 23:07:04 2015 +0900 +++ b/mercurial/revset.py Mon Feb 02 23:07:04 2015 +0900 @@ -2324,16 +2324,8 @@ ' "%s": %s') % (self.name, self.error) return - if self.args: - for arg in self.args: - # _aliasarg() is an unknown symbol only used separate - # alias argument placeholders from regular strings. - value = value.replace(arg, '_aliasarg(%r)' % (arg,)) - try: - self.replacement, pos = parse(value) - if pos != len(value): - raise error.ParseError(_('invalid token'), pos) + self.replacement = _parsealiasdefn(value, self.args) # Check for placeholder injection _checkaliasarg(self.replacement, self.args) except error.ParseError, inst:
--- a/tests/test-revset.t Mon Feb 02 23:07:04 2015 +0900 +++ b/tests/test-revset.t Mon Feb 02 23:07:04 2015 +0900 @@ -1024,6 +1024,19 @@ ('symbol', 'tip') warning: failed to parse the declaration of revset alias "bad name": at 4: invalid token 9 + $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc + $ try 'strictreplacing("foo", tip)' + (func + ('symbol', 'strictreplacing') + (list + ('string', 'foo') + ('symbol', 'tip'))) + (or + ('symbol', 'tip') + (func + ('symbol', 'desc') + ('string', '$1'))) + 9 $ try 'd(2:5)' (func