diff genshi/template/loader.py @ 661:c7dcd4dc240d experimental-sandboxed

loader raises an SecurityException in restricted mode if absolute paths are used
author aronacher
date Thu, 29 Nov 2007 18:51:48 +0000
parents 5af131b37ab4
children e097006dccfa
line wrap: on
line diff
--- a/genshi/template/loader.py
+++ b/genshi/template/loader.py
@@ -19,7 +19,7 @@
 except ImportError:
     import dummy_threading as threading
 
-from genshi.template.base import TemplateError
+from genshi.template.base import TemplateError, SecurityError
 from genshi.util import LRUCache
 
 __all__ = ['TemplateLoader', 'TemplateNotFound']
@@ -185,6 +185,9 @@
 
             if os.path.isabs(filename):
                 # Bypass the search path if the requested filename is absolute
+                # but raise an exception if we are in restricted mode.
+                if self.restricted:
+                    raise SecurityError()
                 search_path = [os.path.dirname(filename)]
                 isabs = True
 
Copyright (C) 2012-2017 Edgewall Software