Use path.parts instead of match (#2508)

This commit is contained in:
Adam Hopkins 2022-07-31 12:54:42 +03:00
parent 86baaef1ec
commit 5b1686ceba
No known key found for this signature in database
GPG Key ID: 9F85EE6C807303FB

View File

@ -787,7 +787,7 @@ class RouteMixin(metaclass=SanicMeta):
file_path = file_path_raw.resolve() file_path = file_path_raw.resolve()
if ( if (
file_path < root_path and not file_path_raw.is_symlink() file_path < root_path and not file_path_raw.is_symlink()
) or file_path_raw.match("../**/*"): ) or ".." in file_path_raw.parts:
error_logger.exception( error_logger.exception(
f"File not found: path={file_or_directory}, " f"File not found: path={file_or_directory}, "
f"relative_url={__file_uri__}" f"relative_url={__file_uri__}"