# HG changeset patch # User Yuya Nishihara # Date 1434377010 -32400 # Node ID babd2c93bd99338aece026a9dbdc07908f9849f4 # Parent 82c918509ef5860496c6d1f3f0d7dd0f7e65024c templater: check existence of closing brace of template string diff -r 82c918509ef5 -r babd2c93bd99 mercurial/templater.py --- a/mercurial/templater.py Mon Jun 15 22:55:34 2015 +0900 +++ b/mercurial/templater.py Mon Jun 15 23:03:30 2015 +0900 @@ -120,12 +120,12 @@ yield ('symbol', sym, s) pos -= 1 elif c == '}': - pos += 1 - break + yield ('end', None, pos + 1) + return else: raise error.ParseError(_("syntax error"), pos) pos += 1 - yield ('end', None, pos) + raise error.ParseError(_("unterminated template expansion"), start) def _parsetemplate(tmpl, start, stop): parsed = [] diff -r 82c918509ef5 -r babd2c93bd99 tests/test-command-template.t --- a/tests/test-command-template.t Mon Jun 15 22:55:34 2015 +0900 +++ b/tests/test-command-template.t Mon Jun 15 23:03:30 2015 +0900 @@ -2513,6 +2513,10 @@ abort: t:3: unmatched quotes [255] + $ hg log -T '{date' + hg: parse error at 1: unterminated template expansion + [255] + Behind the scenes, this will throw TypeError $ hg log -l 3 --template '{date|obfuscate}\n'