mirror of https://github.com/pallets/flask.git
remove deprecated safe_join
This commit is contained in:
parent
218534a9f2
commit
b7501776a1
|
@ -13,6 +13,8 @@ Unreleased
|
||||||
- ``config.from_json`` is replaced by
|
- ``config.from_json`` is replaced by
|
||||||
``config.from_file(name, load=json.load)``.
|
``config.from_file(name, load=json.load)``.
|
||||||
- ``json`` functions no longer take an ``encoding`` parameter.
|
- ``json`` functions no longer take an ``encoding`` parameter.
|
||||||
|
- ``safe_join`` is removed, use ``werkzeug.utils.safe_join``
|
||||||
|
instead.
|
||||||
|
|
||||||
|
|
||||||
Version 2.0.2
|
Version 2.0.2
|
||||||
|
|
|
@ -218,8 +218,6 @@ Useful Functions and Classes
|
||||||
|
|
||||||
.. autofunction:: send_from_directory
|
.. autofunction:: send_from_directory
|
||||||
|
|
||||||
.. autofunction:: safe_join
|
|
||||||
|
|
||||||
.. autofunction:: escape
|
.. autofunction:: escape
|
||||||
|
|
||||||
.. autoclass:: Markup
|
.. autoclass:: Markup
|
||||||
|
|
|
@ -23,7 +23,6 @@ from .helpers import flash as flash
|
||||||
from .helpers import get_flashed_messages as get_flashed_messages
|
from .helpers import get_flashed_messages as get_flashed_messages
|
||||||
from .helpers import get_template_attribute as get_template_attribute
|
from .helpers import get_template_attribute as get_template_attribute
|
||||||
from .helpers import make_response as make_response
|
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_file as send_file
|
||||||
from .helpers import send_from_directory as send_from_directory
|
from .helpers import send_from_directory as send_from_directory
|
||||||
from .helpers import stream_with_context as stream_with_context
|
from .helpers import stream_with_context as stream_with_context
|
||||||
|
|
|
@ -11,7 +11,6 @@ from functools import update_wrapper
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
|
|
||||||
import werkzeug.utils
|
import werkzeug.utils
|
||||||
from werkzeug.exceptions import NotFound
|
|
||||||
from werkzeug.routing import BuildError
|
from werkzeug.routing import BuildError
|
||||||
from werkzeug.urls import url_quote
|
from werkzeug.urls import url_quote
|
||||||
|
|
||||||
|
@ -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(
|
def send_from_directory(
|
||||||
directory: t.Union[os.PathLike, str],
|
directory: t.Union[os.PathLike, str],
|
||||||
path: t.Union[os.PathLike, str],
|
path: t.Union[os.PathLike, str],
|
||||||
|
|
Loading…
Reference in New Issue