diff roundup/cgi/client.py @ 5154:f608eeecf638

issue2550891: Allow subdir in template value. Anthony (antmail) requested the ability to put templates into subdirectories. So the issue class can accept @template=issues/item to get the html/issues/issue.item.html template. Inlcude a test case for missing and existing (tal) templates. Also include a test that fails path traversal check. Add mention of subdiectoy use to customizing.txt along with some spelling fixes and ^M removal.
author John Rouillard <rouilj@ieee.org>
date Fri, 22 Jul 2016 15:19:40 -0400
parents 748ba87e1aca
children a86860224d80
line wrap: on
line diff
--- a/roundup/cgi/client.py	Wed Jul 20 22:30:35 2016 -0400
+++ b/roundup/cgi/client.py	Fri Jul 22 15:19:40 2016 -0400
@@ -1157,7 +1157,17 @@
 
         tplname = name     
         if view:
-            tplname = '%s.%s' % (name, view)
+            # Support subdirectories for templates. Value is path/to/VIEW
+            # or just VIEW if the template is in the html directory of
+            # the tracker.
+            slash_loc = view.rfind("/")
+            if slash_loc == -1:
+                # try plain class.view
+                tplname = '%s.%s' % (name, view)
+            else:
+                # try path/class.view
+                tplname = '%s/%s.%s'%(
+                    view[:slash_loc], name, view[slash_loc+1:])
 
         if loader.check(tplname):
             return tplname
@@ -1167,7 +1177,10 @@
         if not view:
             raise templating.NoTemplate('Template "%s" doesn\'t exist' % name)
 
-        generic = '_generic.%s' % view
+        if slash_loc == -1:
+            generic = '_generic.%s' % view
+        else:
+            generic = '%s/_generic.%s' % (view[:slash_loc], view[slash_loc+1:])
         if loader.check(generic):
             return generic
 

Roundup Issue Tracker: http://roundup-tracker.org/