commitextras: make sure keys are not empty stable
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 30 Jul 2017 12:19:46 +0530
branchstable
changeset 33606 806351695c6a
parent 33605 92f7dcf9a40b
child 33607 6c142f279625
commitextras: make sure keys are not empty Thanks to Yuya for catching this.
hgext/commitextras.py
tests/test-commit.t
--- a/hgext/commitextras.py	Sat Jul 29 19:12:48 2017 -0700
+++ b/hgext/commitextras.py	Sun Jul 30 12:19:46 2017 +0530
@@ -54,6 +54,9 @@
                                 "KEY=VALUE format")
                         raise error.Abort(msg % raw)
                     k, v = raw.split('=', 1)
+                    if not k:
+                        msg = _("unable to parse '%s', keys can't be empty")
+                        raise error.Abort(msg % raw)
                     if re.search('[^\w-]', k):
                         msg = _("keys can only contain ascii letters, digits,"
                                 " '_' and '-'")
--- a/tests/test-commit.t	Sat Jul 29 19:12:48 2017 -0700
+++ b/tests/test-commit.t	Sun Jul 30 12:19:46 2017 +0530
@@ -138,6 +138,9 @@
   $ hg commit -m "special chars in extra" --extra id@phab=214
   abort: keys can only contain ascii letters, digits, '_' and '-'
   [255]
+  $ hg commit -m "empty key" --extra =value
+  abort: unable to parse '=value', keys can't be empty
+  [255]
   $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar
   $ hg log -r . -T '{extras % "{extra}\n"}'
   branch=default