Skip to content
Myr

normpath is now used before loading templates

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 38107c7 · Browse files · 4 files+14 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+14 added−0 removed

  • tests:+7 added−0 removed
  • other:+7 added−0 removed

4 files+14 added−0 removed

modified:flask/templating.py+4 added
6 unmodified lines
78 :copyright: (c) 2010 by Armin Ronacher.9 :license: BSD, see LICENSE for more details.10"""11import posixpath12from jinja2 import BaseLoader, TemplateNotFound1314from .globals import _request_ctx_stack15from .signals import template_rendered
20 unmodified lines
36 def __init__(self, app):37 self.app = app3839 def get_source(self, environment, template):40 template = posixpath.normpath(template)41 if template.startswith('../'):42 raise TemplateNotFound(template)43 loader = None44 try:45 module, name = template.split('/', 1)46 loader = self.app.modules[module].jinja_loader
54 unmodified lines
modified:tests/moduleapp/apps/admin/__init__.py+5 added
5 unmodified lines
67@admin.route('/')8def index():9 return render_template('admin/index.html')101112@admin.route('/index2')13def index2():14 return render_template('./admin/index.html')
modified:tests/flask_tests.py+2 added
787 unmodified lines
788 rv = c.get('/')789 assert rv.data == 'Hello from the Frontend'790 rv = c.get('/admin/')791 assert rv.data == 'Hello from the Admin'792 rv = c.get('/admin/index2')793 assert rv.data == 'Hello from the Admin'794 rv = c.get('/admin/static/test.txt')795 assert rv.data.strip() == 'Admin File'796 rv = c.get('/admin/static/css/test.css')797 assert rv.data.strip() == '/* nested file */'
437 unmodified lines
modified:CHANGES+3 added
23 unmodified lines
24Bugfix release, release date to be announced.2526- Fixed an issue where the default `OPTIONS` response was27 not exposing all valid methods in the `Allow` header.28- Jinja2 template loading syntax now allows "./" in front of29 a template load path. Previously this caused issues with30 module setups.3132Version 0.633-----------34
143 unmodified lines