Mercurial > hg
changeset 33602:27fbca750b4d stable
commitextras: make sure keys contains ascii letters, numbers, '_' and '-' only
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 28 Jul 2017 07:42:55 +0530 |
parents | 850d2ec2cf6a |
children | 075823a6161b |
files | hgext/commitextras.py tests/test-commit.t |
diffstat | 2 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/commitextras.py Thu Jul 27 12:03:01 2017 -0700 +++ b/hgext/commitextras.py Fri Jul 28 07:42:55 2017 +0530 @@ -9,6 +9,8 @@ from __future__ import absolute_import +import re + from mercurial.i18n import _ from mercurial import ( commands, @@ -52,6 +54,10 @@ "KEY=VALUE format") raise error.Abort(msg % raw) k, v = raw.split('=', 1) + if re.search('[^\w-]', k): + msg = _("keys can only contain ascii letters, digits," + " '_' and '-'") + raise error.Abort(msg) if k in usedinternally: msg = _("key '%s' is used internally, can't be set " "manually")
--- a/tests/test-commit.t Thu Jul 27 12:03:01 2017 -0700 +++ b/tests/test-commit.t Fri Jul 28 07:42:55 2017 +0530 @@ -135,6 +135,9 @@ $ hg commit -m "adding internal used extras" --extra amend_source=hash abort: key 'amend_source' is used internally, can't be set manually [255] + $ hg commit -m "special chars in extra" --extra id@phab=214 + abort: keys can only contain ascii letters, digits, '_' and '-' + [255] $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar $ hg log -r . -T '{extras % "{extra}\n"}' branch=default