Commits

Christian Boos committed 7f6a5c4

Ported attachment link bug fix [2545] to 0.9-stable

Comments (0)

Files changed (2)

trac/attachment.py

                     parent_type = path_info[1]
                 if len(path_info) > 2:
                     parent_id = path_info[2]
-            idx = link.find('?')
-            if idx < 0:
-                filename = link
-            else:
-                filename = link[:idx]
-                params = link[idx:]
+            filename = link
+        idx = filename.find('?')
+        if idx >= 0:
+            filename, params = filename[:idx], filename[idx:]
         try:
             attachment = Attachment(self.env, parent_type, parent_id, filename)
             return '<a class="attachment" title="Attachment %s" href="%s">%s</a>' \

trac/tests/attachment.py

                          'foo.txt" href="/trac.cgi/attachment/ticket/123/'
                          'foo.txt">Foo</a>',
                          func(formatter, ns, 'ticket:123:foo.txt', 'Foo'))
+        self.assertEqual('<a class="attachment" title="Attachment #123: '
+                         'foo.txt" href="/trac.cgi/attachment/ticket/123/'
+                         'foo.txt?format=raw">Foo</a>',
+                         func(formatter, ns, 'ticket:123:foo.txt?format=raw',
+                              'Foo'))
 
 
 def suite():