Skip to content

Commit

Permalink
remove deprecated safe_join
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Nov 12, 2021
1 parent 218534a commit b750177
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Unreleased
- ``config.from_json`` is replaced by
``config.from_file(name, load=json.load)``.
- ``json`` functions no longer take an ``encoding`` parameter.
- ``safe_join`` is removed, use ``werkzeug.utils.safe_join``
instead.


Version 2.0.2
Expand Down
2 changes: 0 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ Useful Functions and Classes

.. autofunction:: send_from_directory

.. autofunction:: safe_join

.. autofunction:: escape

.. autoclass:: Markup
Expand Down
1 change: 0 additions & 1 deletion src/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from .helpers import get_flashed_messages as get_flashed_messages
from .helpers import get_template_attribute as get_template_attribute
from .helpers import make_response as make_response
from .helpers import safe_join as safe_join
from .helpers import send_file as send_file
from .helpers import send_from_directory as send_from_directory
from .helpers import stream_with_context as stream_with_context
Expand Down
24 changes: 0 additions & 24 deletions src/flask/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from threading import RLock

import werkzeug.utils
from werkzeug.exceptions import NotFound
from werkzeug.routing import BuildError
from werkzeug.urls import url_quote

Expand Down Expand Up @@ -627,29 +626,6 @@ def send_file(
)


def safe_join(directory: str, *pathnames: str) -> str:
"""Safely join zero or more untrusted path components to a base
directory to avoid escaping the base directory.
:param directory: The trusted base directory.
:param pathnames: The untrusted path components relative to the
base directory.
:return: A safe path, otherwise ``None``.
"""
warnings.warn(
"'flask.helpers.safe_join' is deprecated and will be removed in"
" Flask 2.1. Use 'werkzeug.utils.safe_join' instead.",
DeprecationWarning,
stacklevel=2,
)
path = werkzeug.utils.safe_join(directory, *pathnames)

if path is None:
raise NotFound()

return path


def send_from_directory(
directory: t.Union[os.PathLike, str],
path: t.Union[os.PathLike, str],
Expand Down

0 comments on commit b750177

Please sign in to comment.