]> arthur.barton.de Git - bup.git/commitdiff
web: retrieve paths exactly as presented
authorRob Browning <rlb@defaultvalue.org>
Sat, 6 Feb 2016 18:02:58 +0000 (12:02 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 12 Mar 2016 18:31:34 +0000 (12:31 -0600)
Bup paths are byte strings, not Unicode, so don't attempt to convert
them to Unicode.  Retrieve exactly what was requested.

Thanks to Mathieu Schroeter for reporting the problem and helping test
the fix.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
cmd/web-cmd.py
t/test-web.sh

index 47817f0e3cdf82182630303e59034cef071a2f30..4add17c1ca20237d10854ce0482ce7ff5d39aa39 100755 (executable)
@@ -84,6 +84,12 @@ def _compute_dir_contents(n, path, show_hidden=False):
 
 
 class BupRequestHandler(tornado.web.RequestHandler):
+
+    def decode_argument(self, value, name=None):
+        if name == 'path':
+            return value
+        return super(BupRequestHandler, self).decode_argument(value, name)
+
     def get(self, path):
         return self._process_request(path)
 
@@ -248,7 +254,7 @@ settings = dict(
 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
 
 application = tornado.web.Application([
-    (r"(/.*)", BupRequestHandler),
+    (r"(?P<path>/.*)", BupRequestHandler),
 ], **settings)
 
 http_server = HTTPServer(application)
index 842b6e9cc900aee6b00be6ada5e55f9fb84d06f1..dd46194ab9ac8e178e6de4aa3048a56e6d8cb3a3 100755 (executable)
@@ -46,17 +46,18 @@ if test -n "$run_test"; then
     WVSTART 'web'
     WVPASS bup init
     WVPASS mkdir src
-    WVPASS echo excitement > src/data
+    WVPASS echo 'éxcitement' > src/data
     WVPASS bup index src
-    WVPASS bup save -n src --strip src
+    WVPASS bup save -n 'éxcitement' --strip src
 
     "$TOP/bup" web unix://socket &
     web_pid=$!
     wait-for-server-start
 
-    WVPASS curl --unix-socket ./socket http://localhost/src/latest/data > result
+    WVPASS curl --unix-socket ./socket \
+           'http://localhost/%C3%A9xcitement/latest/data' > result
 
-    WVPASSEQ excitement "$(cat result)"
+    WVPASSEQ 'éxcitement' "$(cat result)"
     WVPASS kill -s TERM "$web_pid"
     WVPASS wait "$web_pid"
 fi