# HG changeset patch # User Yuya Nishihara # Date 1489837124 -32400 # Node ID 3725986b151aebeb11bfabb169bbef1e51a98fef # Parent 43d6ef658874c26cfd4d0a53840487b492d9b5cb templater: reject bad fillchar argument passed to pad() Otherwise TypeError would be raised. diff -r 43d6ef658874 -r 3725986b151a mercurial/templater.py --- a/mercurial/templater.py Sat Mar 18 20:11:15 2017 +0900 +++ b/mercurial/templater.py Sat Mar 18 20:38:44 2017 +0900 @@ -575,6 +575,9 @@ fillchar = ' ' if len(args) > 2: fillchar = evalstring(context, mapping, args[2]) + if len(fillchar) != 1: + # i18n: "pad" is a keyword + raise error.ParseError(_("pad() expects a single fill character")) if len(args) > 3: left = evalboolean(context, mapping, args[3]) diff -r 43d6ef658874 -r 3725986b151a tests/test-command-template.t --- a/tests/test-command-template.t Sat Mar 18 20:11:15 2017 +0900 +++ b/tests/test-command-template.t Sat Mar 18 20:38:44 2017 +0900 @@ -3521,6 +3521,15 @@ hg: parse error: pad() expects an integer width [255] +Test invalid fillchar passed to pad function + + $ hg log -r 0 -T '{pad(rev, 10, "")}\n' + hg: parse error: pad() expects a single fill character + [255] + $ hg log -r 0 -T '{pad(rev, 10, "--")}\n' + hg: parse error: pad() expects a single fill character + [255] + Test boolean argument passed to pad function no crash