Skip to content
Myr

fixed possible security problem in module branch

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 f1cde5b · Browse files · 2 files+22 added−1 removed
This commit

State

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

Diff stats

2 files+22 added−1 removed

  • tests:+20 added−0 removed
  • other:+2 added−1 removed

2 files+22 added−1 removed

modified:flask/helpers.py+2 added-1 removed
27 unmodified lines
28 except ImportError:29 json_available = False3031from werkzeug import Headers, wrap_file, is_resource_modified, cached_property32from werkzeug.exceptions import NotFound3334from jinja2 import FileSystemLoader3536from .globals import session, _request_ctx_stack, current_app, request
297 unmodified lines
334335 .. versionadded:: 0.5336 """337 filename = posixpath.normpath(filename)337 if filename.startswith('../'):338 if filename.startswith(('/', '../')):339 raise NotFound()340 filename = os.path.join(self.root_path, 'static', filename)341 if not os.path.isfile(filename):342 raise NotFound()
29 unmodified lines
modified:tests/flask_tests.py+20 added
18 unmodified lines
19from logging import StreamHandler20from contextlib import contextmanager21from datetime import datetime22from werkzeug import parse_date, parse_options_header23from werkzeug.exceptions import NotFound24from cStringIO import StringIO2526example_path = os.path.join(os.path.dirname(__file__), '..', 'examples')27sys.path.append(os.path.join(example_path, 'flaskr'))
617 unmodified lines
645 with app.test_request_context():646 assert flask.url_for('admin.static', filename='test.txt') \647 == '/admin/static/test.txt'648649 def test_safe_access(self):650 from moduleapp import app651652 with app.test_request_context():653 f = app.view_functions['admin.static']654655 try:656 rv = f('/etc/passwd')657 except NotFound:658 pass659 else:660 assert 0, 'expected exception'661 try:662 rv = f('../__init__.py')663 except NotFound:664 pass665 else:666 assert 0, 'expected exception'667668669class SendfileTestCase(unittest.TestCase):670671 def test_send_file_regular(self):672 app = flask.Flask(__name__)
260 unmodified lines