bugfix: FileComponent fixes exception when uploading compressed files on mac (#7061)

* bugfix: FileComponent fixes exception when uploading compressed files on mac

* [autofix.ci] apply automated fixes

* Change the way use the os package to use the imported Path() function

---------

Co-authored-by: zhangliang1-jk <zhangliang1-jk@360shuke.com>
Co-authored-by: Eric Hare <ericrhare@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
zhangliang
2025-10-11 00:42:03 +08:00
committed by GitHub
parent a3f7f918ea
commit 4b32df50cb

View File

@ -672,6 +672,9 @@ class BaseFileComponent(Component, ABC):
def _safe_extract_zip(bundle: ZipFile, output_dir: Path):
"""Safely extract ZIP files."""
for member in bundle.namelist():
# Filter out resource fork information for automatic production of mac
if Path(member).name.startswith("._"):
continue
member_path = output_dir / member
# Ensure no path traversal outside `output_dir`
if not member_path.resolve().is_relative_to(output_dir.resolve()):
@ -682,6 +685,9 @@ class BaseFileComponent(Component, ABC):
def _safe_extract_tar(bundle: tarfile.TarFile, output_dir: Path):
"""Safely extract TAR files."""
for member in bundle.getmembers():
# Filter out resource fork information for automatic production of mac
if Path(member.name).name.startswith("._"):
continue
member_path = output_dir / member.name
# Ensure no path traversal outside `output_dir`
if not member_path.resolve().is_relative_to(output_dir.resolve()):