Skip to content
Myr

Make sure that windows servers do not allow downloading arbitrary files

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 fb88d9d · Browse files · 1 file+11 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

1 file+11 added−1 removed

  • other:+11 added−1 removed

1 file+11 added−1 removed

modified:flask/helpers.py+11 added-1 removed
56 unmodified lines
57else:58 _tojson_filter = json.dumps596061# what separators does this operating system provide that are not a slash?62# this is used by the send_from_directory function to ensure that nobody is63# able to access files from outside the filesystem.64_os_alt_seps = list(sep for sep in [os.path.sep, os.path.altsep]65 if sep not in (None, '/'))666768def _endpoint_from_view_func(view_func):69 """Internal helper that returns the default endpoint for a given70 function. This always is the function name.71 """
347 unmodified lines
419 :param options: optional keyword arguments that are directly420 forwarded to :func:`send_file`.421 """422 filename = posixpath.normpath(filename)416 if filename.startswith(('/', '../')):423 for sep in _os_alt_seps:424 if sep in filename:425 raise NotFound()426 if os.path.isabs(filename) or filename.startswith('../'):427 raise NotFound()428 filename = os.path.join(directory, filename)429 if not os.path.isfile(filename):430 raise NotFound()
70 unmodified lines