-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# TODO: Use Werkzeug's directly after dropping support for older Flask versions | ||
try: | ||
# Use older Flask implementation directly to ensure backwards compatibility | ||
from flask import safe_join | ||
except ImportError: | ||
import werkzeug.utils | ||
from werkzeug.exceptions import NotFound | ||
|
||
# Use port of Flask 2.0 safe_join to match behavior | ||
def safe_join(directory, *pathnames): | ||
"""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. | ||
""" | ||
path = werkzeug.utils.safe_join(directory, *pathnames) | ||
|
||
if path is None: | ||
raise NotFound() | ||
|
||
return path | ||
|
||
|
||
__all__ = ['safe_join'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ Markdown>=2.5.1 | |
path-and-address>=2.0.1 | ||
Pygments>=1.6 | ||
requests>=2.4.1 | ||
Werkzeug>=2.1.0 | ||
Werkzeug>=0.7 |