# HG changeset patch # User Pierre-Yves David # Date 2014-04-17 05:03:33 # Node ID 341a083603a545dfe06ce0934d8cf03cc6b98427 # Parent b6fd496e5c7270313c7a127292883822e490e66d bundle2: protect capabilities name and values with url quoting This lift limitations of the text based encoding. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -712,6 +712,8 @@ def handlereplycaps(op, inpart): else: key, vals = line.split('=', 1) vals = vals.split(',') + key = urllib.unquote(key) + vals = [urllib.unquote(v) for v in vals] caps[key] = vals if op.reply is None: op.reply = bundle20(op.ui, caps) diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t --- a/tests/test-bundle2.t +++ b/tests/test-bundle2.t @@ -72,7 +72,7 @@ Create an extension to test bundle2 API > raise util.Abort('%s' % exc) > > if opts['reply']: - > capsstring = 'ping-pong\nelephants=babar,celeste\ncity=celesteville' + > capsstring = 'ping-pong\nelephants=babar,celeste\ncity%3D%21=celeste%2Cville' > bundler.addpart(bundle2.bundlepart('replycaps', data=capsstring)) > > revs = opts['rev'] @@ -547,9 +547,9 @@ The reply is a bundle Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. - \x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to4\x00\x00\x00\xc6debugreply: capabilities: (esc) - debugreply: 'city' - debugreply: 'celesteville' + \x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to4\x00\x00\x00\xc9debugreply: capabilities: (esc) + debugreply: 'city=!' + debugreply: 'celeste,ville' debugreply: 'elephants' debugreply: 'babar' debugreply: 'celeste' @@ -569,7 +569,7 @@ The reply is valid :output: mandatory: 0 advisory: 1 - payload: 198 bytes + payload: 201 bytes :test:pong: mandatory: 1 advisory: 0 @@ -588,8 +588,8 @@ Unbundle the reply to get the output: remote: Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko remote: Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko. remote: debugreply: capabilities: - remote: debugreply: 'city' - remote: debugreply: 'celesteville' + remote: debugreply: 'city=!' + remote: debugreply: 'celeste,ville' remote: debugreply: 'elephants' remote: debugreply: 'babar' remote: debugreply: 'celeste'