Comments
Patch
@@ -43,20 +43,21 @@ Binary format is as follow
parameters.
The blob contains a space separated list of parameters. parameter with value
are stored in the form `<name>=<value>`. Both name and value are urlquoted.
+ Empty name are obviously forbidden.
+
Stream parameters use a simple textual format for two main reasons:
- Stream level parameters should remains simple and we want to discourage any
crazy usage.
- Textual data allow easy human inspection of a the bundle2 header in case of
troubles.
Any Applicative level options MUST go into a bundle2 part instead.
-
Payload part
------------------------
Binary format is as follow
@@ -95,10 +96,12 @@ class bundle20(object):
self._params = []
self._parts = []
def addparam(self, name, value=None):
"""add a stream level parameter"""
+ if not name:
+ raise ValueError('empty parameter name')
self._params.append((name, value))
def getchunks(self):
yield _magicstring
param = self._paramchunk()
@@ -8,10 +8,11 @@ Create an extension to test bundle2 API
> code. We still need to be able to test it while it grow up.
> """
>
> import sys
> from mercurial import cmdutil
+ > from mercurial import util
> from mercurial import bundle2
> cmdtable = {}
> command = cmdutil.command(cmdtable)
>
> @command('bundle2',
@@ -20,11 +21,14 @@ Create an extension to test bundle2 API
> def cmdbundle2(ui, repo, **opts):
> """write a bundle2 container on standard ouput"""
> bundler = bundle2.bundle20()
> for p in opts['param']:
> p = p.split('=', 1)
- > bundler.addparam(*p)
+ > try:
+ > bundler.addparam(*p)
+ > except ValueError, exc:
+ > raise util.Abort('%s' % exc)
>
> for chunk in bundler.getchunks():
> ui.write(chunk)
>
> @command('unbundle2', [], '')
@@ -147,5 +151,14 @@ Test unbundling
options count: 2
- e|! 7/
babar%#==tutu
- simple
parts count: 0
+
+Test buggy input
+---------------------------------------------------
+
+empty parameter name
+
+ $ hg bundle2 --param '' --quiet
+ abort: empty parameter name
+ [255]