Code

Ticket #9666: ssi-variable.diff

File ssi-variable.diff, 1.2 KB (added by UloPe, 5 years ago)

fixed ssi variable resolving

Line 
1Index: django/template/defaulttags.py
2===================================================================
3--- django/template/defaulttags.py      (revision 10095)
4+++ django/template/defaulttags.py      (working copy)
5@@ -298,20 +298,25 @@
6         self.filepath, self.parsed = filepath, parsed
7 
8     def render(self, context):
9-        if not include_is_allowed(self.filepath):
10+        filepath = self.filepath
11+        try:
12+            filepath = Variable(filepath).resolve(context)
13+        except VariableDoesNotExist:
14+            pass
15+        if not include_is_allowed(filepath):
16             if settings.DEBUG:
17                 return "[Didn't have permission to include file]"
18             else:
19                 return '' # Fail silently for invalid includes.
20         try:
21-            fp = open(self.filepath, 'r')
22+            fp = open(filepath, 'r')
23             output = fp.read()
24             fp.close()
25         except IOError:
26             output = ''
27         if self.parsed:
28             try:
29-                t = Template(output, name=self.filepath)
30+                t = Template(output, name=filepath)
31                 return t.render(context)
32             except TemplateSyntaxError, e:
33                 if settings.DEBUG: