changeset 21137:341a083603a5

bundle2: protect capabilities name and values with url quoting This lift limitations of the text based encoding.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Apr 2014 01:03:33 -0400
parents b6fd496e5c72
children f469879d27ec
files mercurial/bundle2.py tests/test-bundle2.t
diffstat 2 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Thu Apr 17 11:44:49 2014 -0400
+++ b/mercurial/bundle2.py	Thu Apr 17 01:03:33 2014 -0400
@@ -712,6 +712,8 @@
         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)
--- a/tests/test-bundle2.t	Thu Apr 17 11:44:49 2014 -0400
+++ b/tests/test-bundle2.t	Thu Apr 17 01:03:33 2014 -0400
@@ -72,7 +72,7 @@
   >             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 @@
       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 @@
     :output:
       mandatory: 0
       advisory: 1
-      payload: 198 bytes
+      payload: 201 bytes
     :test:pong:
       mandatory: 1
       advisory: 0
@@ -588,8 +588,8 @@
   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'