Skip to content
Snippets Groups Projects
Commit 1504fc60 authored by donkopotamus's avatar donkopotamus
Browse files

Move calculation of normalised uri to the codepath where it is actually used

- this fixes a bug in the mako-render script which refuses to process a filename
  that is given as a relative path
parent 62926b5d
No related branches found
No related tags found
No related merge requests found
......@@ -255,16 +255,6 @@ class Template(object):
self.module_id = "memory:" + hex(id(self))
self.uri = self.module_id
u_norm = self.uri
if u_norm.startswith("/"):
u_norm = u_norm[1:]
u_norm = os.path.normpath(u_norm)
if u_norm.startswith(".."):
raise exceptions.TemplateLookupException(
"Template uri \"%s\" is invalid - "
"it cannot be relative outside "
"of the root path." % self.uri)
self.input_encoding = input_encoding
self.output_encoding = output_encoding
self.encoding_errors = encoding_errors
......@@ -310,6 +300,16 @@ class Template(object):
if module_filename is not None:
path = module_filename
elif module_directory is not None:
u_norm = self.uri
if u_norm.startswith("/"):
u_norm = u_norm[1:]
u_norm = os.path.normpath(u_norm)
if u_norm.startswith(".."):
raise exceptions.TemplateLookupException(
"Template uri \"%s\" is invalid - "
"it cannot be relative outside "
"of the root path." % self.uri)
path = os.path.abspath(
os.path.join(
os.path.normpath(module_directory),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment