]> arthur.barton.de Git - bup.git/commitdiff
web: URL escape link components 0.27-rc1
authorRob Browning <rlb@defaultvalue.org>
Mon, 16 Feb 2015 19:13:09 +0000 (13:13 -0600)
committerRob Browning <rlb@defaultvalue.org>
Mon, 16 Feb 2015 19:13:09 +0000 (13:13 -0600)
So that links for path names like directory:80 won't be broken.

Thanks to Euan Kemp for reporting the problem and proposing an earlier
fix.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
cmd/web-cmd.py
lib/web/list-directory.html

index fc4d117d4c6ef582a3a5cf72fa131e731794139d..1c515e2d10d6ddfa0d488311adcd1f73315f11d8 100755 (executable)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 import sys, stat, urllib, mimetypes, posixpath, time, webbrowser
+import urllib
 from bup import options, git, vfs
 from bup.helpers import *
 try:
@@ -47,21 +48,22 @@ def _compute_dir_contents(n, path, show_hidden=False):
     if path != "/":
         yield('..', '../' + url_append, '')
     for sub in n:
-        display = link = sub.name
+        display = sub.name
+        link = urllib.quote(sub.name)
 
         # link should be based on fully resolved type to avoid extra
         # HTTP redirect.
         if stat.S_ISDIR(sub.try_resolve().mode):
-            link = sub.name + "/"
+            link += "/"
 
         if not show_hidden and len(display)>1 and display.startswith('.'):
             continue
 
         size = None
         if stat.S_ISDIR(sub.mode):
-            display = sub.name + '/'
+            display += '/'
         elif stat.S_ISLNK(sub.mode):
-            display = sub.name + '@'
+            display += '@'
         else:
             size = sub.size()
             size = (opt.human_readable and format_filesize(size)) or size
index 54668fb21ca1e37077915d879d9568739a91b56d..45b1f1d22e2e11ebca80bcc0906c9241ee4cb06e 100644 (file)
@@ -1,3 +1,4 @@
+{% comment This template expects the default xhtml autoescaping. %}
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
     <head>
@@ -29,7 +30,9 @@
                 </tr>
                 {% for (display, link, size) in dir_contents %}
                 <tr>
-                    <td class="dir-name"><a href="{{ link }}">{{ display }}</a></td>
+                    <td class="dir-name">
+                      <a href="{% raw link %}">{{ display }}</a>
+                    </td>
                     <td class="dir-size">{% if size != None %}{{ size }}{% else %}&nbsp;{% end %}</td>
                 </tr>
                 {% end %}