Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revsetlang.py @ 35592:0fd617afebc0
revsetlang: check number of arguments passed to formatspec()
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 01 Apr 2017 17:25:45 +0900 |
parents | 8f1a7adb3225 |
children | 850cd045b1df |
line wrap: on
line diff
--- a/mercurial/revsetlang.py Sat Apr 01 17:18:31 2017 +0900 +++ b/mercurial/revsetlang.py Sat Apr 01 17:25:45 2017 +0900 @@ -634,15 +634,27 @@ d = expr[pos] if d == '%': ret.append(d) - elif d == 'l': + pos += 1 + continue + + try: + arg = next(argiter) + except StopIteration: + raise error.ParseError(_('missing argument for revspec')) + if d == 'l': # a list of some type pos += 1 d = expr[pos] - ret.append(listexp(list(next(argiter)), d)) + ret.append(listexp(list(arg), d)) else: - ret.append(argtype(d, next(argiter))) + ret.append(argtype(d, arg)) pos += 1 + try: + next(argiter) + raise error.ParseError(_('too many revspec arguments specified')) + except StopIteration: + pass return ''.join(ret) def prettyformat(tree):