diff --git a/python/dgl/data/utils.py b/python/dgl/data/utils.py index 0719b97cabc2..b83cceac76f2 100644 --- a/python/dgl/data/utils.py +++ b/python/dgl/data/utils.py @@ -244,7 +244,7 @@ def check_sha1(filename, sha1_hash): return sha1.hexdigest() == sha1_hash -def extract_archive(file, target_dir, overwrite=True): +def extract_archive(file, target_dir, overwrite=True, filter="data"): """Extract archive file. Parameters @@ -282,7 +282,9 @@ def safe_extract( member_path = os.path.join(path, member.name) if not is_within_directory(path, member_path): raise Exception("Attempted Path Traversal in Tar File") - tar.extractall(path, members, numeric_owner=numeric_owner) + tar.extractall( + path, members, numeric_owner=numeric_owner, filter=filter + ) safe_extract(archive, path=target_dir) elif file.endswith(".gz"): diff --git a/python/dgl/graphbolt/internal_utils.py b/python/dgl/graphbolt/internal_utils.py index 089050ad83b6..1cf641bc9598 100644 --- a/python/dgl/graphbolt/internal_utils.py +++ b/python/dgl/graphbolt/internal_utils.py @@ -313,7 +313,7 @@ def check_sha1(filename, sha1_hash): return sha1.hexdigest() == sha1_hash -def extract_archive(file, target_dir, overwrite=True): +def extract_archive(file, target_dir, overwrite=True, filter="data"): """Extract archive file. Parameters @@ -351,7 +351,9 @@ def safe_extract( member_path = os.path.join(path, member.name) if not is_within_directory(path, member_path): raise Exception("Attempted Path Traversal in Tar File") - tar.extractall(path, members, numeric_owner=numeric_owner) + tar.extractall( + path, members, numeric_owner=numeric_owner, filter=filter + ) safe_extract(archive, path=target_dir) elif file.endswith(".gz"):