Permalink
Browse files

normpath is now used before loading templates

  • Loading branch information...
1 parent 38107c7 commit a3a843999b8f98a96fb44f573515d44648d72bab @mitsuhiko mitsuhiko committed Aug 9, 2010
Showing with 14 additions and 0 deletions.
  1. +3 −0 CHANGES
  2. +4 −0 flask/templating.py
  3. +2 −0 tests/flask_tests.py
  4. +5 −0 tests/moduleapp/apps/admin/__init__.py
View
3 CHANGES
@@ -25,6 +25,9 @@ Bugfix release, release date to be announced.
- Fixed an issue where the default `OPTIONS` response was
not exposing all valid methods in the `Allow` header.
+- Jinja2 template loading syntax now allows "./" in front of
+ a template load path. Previously this caused issues with
+ module setups.
Version 0.6
-----------
View
4 flask/templating.py
@@ -8,6 +8,7 @@
:copyright: (c) 2010 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
+import posixpath
from jinja2 import BaseLoader, TemplateNotFound
from .globals import _request_ctx_stack
@@ -36,6 +37,9 @@ def __init__(self, app):
self.app = app
def get_source(self, environment, template):
+ template = posixpath.normpath(template)
+ if template.startswith('../'):
+ raise TemplateNotFound(template)
loader = None
try:
module, name = template.split('/', 1)
View
2 tests/flask_tests.py
@@ -789,6 +789,8 @@ def test_templates_and_static(self):
assert rv.data == 'Hello from the Frontend'
rv = c.get('/admin/')
assert rv.data == 'Hello from the Admin'
+ rv = c.get('/admin/index2')
+ assert rv.data == 'Hello from the Admin'
rv = c.get('/admin/static/test.txt')
assert rv.data.strip() == 'Admin File'
rv = c.get('/admin/static/css/test.css')
View
5 tests/moduleapp/apps/admin/__init__.py
@@ -7,3 +7,8 @@
@admin.route('/')
def index():
return render_template('admin/index.html')
+
+
+@admin.route('/index2')
+def index2():
+ return render_template('./admin/index.html')

0 comments on commit a3a8439

Please sign in to comment.