Skip to content

Commit 59f8823

Browse files
committed
refac
1 parent 7f90073 commit 59f8823

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

core/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ class UserInputError(Exception):
3232

3333
# Directories from which local file reads are allowed.
3434
# The user's home directory is the default safe base.
35-
# Override via ALLOWED_FILE_DIRS env var (colon-separated paths).
35+
# Override via ALLOWED_FILE_DIRS env var (os.pathsep-separated paths).
3636
_ALLOWED_FILE_DIRS_ENV = "ALLOWED_FILE_DIRS"
3737

3838

3939
def _get_allowed_file_dirs() -> list[Path]:
4040
"""Return the list of directories from which local file access is permitted."""
4141
env_val = os.environ.get(_ALLOWED_FILE_DIRS_ENV)
4242
if env_val:
43-
return [Path(p).resolve() for p in env_val.split(":") if p.strip()]
43+
return [Path(p).expanduser().resolve() for p in env_val.split(os.pathsep) if p.strip()]
4444
home = Path.home()
4545
return [home] if home else []
4646

gdrive/drive_tools.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -733,14 +733,7 @@ def _resolve_and_validate_host(hostname: str) -> list[str]:
733733
for _family, _type, _proto, _canonname, sockaddr in addr_infos:
734734
ip_str = sockaddr[0]
735735
ip = ipaddress.ip_address(ip_str)
736-
if (
737-
ip.is_private
738-
or ip.is_loopback
739-
or ip.is_reserved
740-
or ip.is_link_local
741-
or ip.is_multicast
742-
or ip.is_unspecified
743-
):
736+
if not ip.is_global:
744737
raise ValueError(
745738
f"URLs pointing to private/internal networks are not allowed: "
746739
f"{hostname} resolves to {ip_str}"

0 commit comments

Comments
 (0)