Skip to content

Commit adeb574

Browse files
committed
Add support for tarfile filters
1 parent 62fdf53 commit adeb574

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

galaxy_importer/collection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ def _import_collection(file, filename, file_url, logger, cfg):
164164

165165
def _extract_archive(fileobj, extract_dir):
166166
fileobj.seek(0)
167+
kwargs = {}
168+
if hasattr(tarfile, "data_filter"):
169+
kwargs["filter"] = "data"
167170
with tarfile.open(fileobj=fileobj, mode="r") as tf:
168171
for item in tf.getmembers():
169172
if item.name.startswith("/") or "../" in item.name:
@@ -175,4 +178,4 @@ def _extract_archive(fileobj, extract_dir):
175178
)
176179
if not link_target.startswith(os.path.abspath(extract_dir)):
177180
raise exc.ImporterError("Invalid link target detected.")
178-
tf.extractall(extract_dir)
181+
tf.extractall(extract_dir, **kwargs)

0 commit comments

Comments
 (0)