Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: use shlex to parse _EDITOR

NTFSvolume0cc3230b265e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 135f128ed..38fd5343f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This affected sites where multiple files may share identical URL path and query, with the fragment being what uniquely identifies each file (Mega.nz, Koofr, Transfer.it)
- Download URL extraction (BuzzHeavier)
- Download of files with no hash information (Filester)
+- Parsing of $EDITOR for paths with spaces
## [10.2.1] - 2026-07-21
diff --git a/cyberdrop_dl/utils/text_editor.py b/cyberdrop_dl/utils/text_editor.py
index f6f5f6884..2d5a91a3a 100644
--- a/cyberdrop_dl/utils/text_editor.py
+++ b/cyberdrop_dl/utils/text_editor.py
@@ -7,6 +7,10 @@ import shutil
import subprocess
import sys
from pathlib import Path
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from collections.abc import Sequence
_TEXT_EDITORS = "micro", "nano", "vim" # Ordered by preference
_SSH = "SSH_CONNECTION" in os.environ
@@ -36,17 +40,22 @@ def open(file_path: Path) -> None: # noqa: A001
@functools.cache
-def _editor_cmd() -> tuple[str, ...] | None:
+def _editor_cmd() -> Sequence[str] | None:
+ import shlex
+
if _CUSTOM_EDITOR:
- name, *rest = _CUSTOM_EDITOR.split(" ")
- path = shutil.which(name)
- if path:
- return path, *rest
+ if shutil.which(_CUSTOM_EDITOR):
+ return (_CUSTOM_EDITOR,)
+
+ cmd = shlex.split(_CUSTOM_EDITOR)
+ if cmd and shutil.which(cmd[0]):
+ return cmd
+
msg = f"Editor '{_CUSTOM_EDITOR}' from env bar $EDITOR is not available. Ignoring"
logger.warning(msg)
if sys.platform == "darwin":
- return "open", "-a", "TextEdit"
+ return "open", "-t", "-n", "-W"
if sys.platform == "win32":
return ("notepad.exe",)