测试gitnore
This commit is contained in:
@@ -23,15 +23,12 @@ def safe_join(base, *paths):
|
||||
# safe_join("/dir", "/../d"))
|
||||
# b) The final path must be the same as the base path.
|
||||
# c) The base path must be the most root path (meaning either "/" or "C:\\")
|
||||
if (
|
||||
not normcase(final_path).startswith(normcase(base_path + sep))
|
||||
and normcase(final_path) != normcase(base_path)
|
||||
and dirname(normcase(base_path)) != normcase(base_path)
|
||||
):
|
||||
if (not normcase(final_path).startswith(normcase(base_path + sep)) and
|
||||
normcase(final_path) != normcase(base_path) and
|
||||
dirname(normcase(base_path)) != normcase(base_path)):
|
||||
raise SuspiciousFileOperation(
|
||||
"The joined path ({}) is located outside of the base path "
|
||||
"component ({})".format(final_path, base_path)
|
||||
)
|
||||
'The joined path ({}) is located outside of the base path '
|
||||
'component ({})'.format(final_path, base_path))
|
||||
return final_path
|
||||
|
||||
|
||||
@@ -42,8 +39,8 @@ def symlinks_supported():
|
||||
permissions).
|
||||
"""
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
original_path = os.path.join(temp_dir, "original")
|
||||
symlink_path = os.path.join(temp_dir, "symlink")
|
||||
original_path = os.path.join(temp_dir, 'original')
|
||||
symlink_path = os.path.join(temp_dir, 'symlink')
|
||||
os.makedirs(original_path)
|
||||
try:
|
||||
os.symlink(original_path, symlink_path)
|
||||
@@ -58,5 +55,5 @@ def to_path(value):
|
||||
if isinstance(value, Path):
|
||||
return value
|
||||
elif not isinstance(value, str):
|
||||
raise TypeError("Invalid path type: %s" % type(value).__name__)
|
||||
raise TypeError('Invalid path type: %s' % type(value).__name__)
|
||||
return Path(value)
|
||||
|
||||
Reference in New Issue
Block a user