topen/test/test_cli.py
Marty Oehme e84adc4392
fix: Correct whitespace separation on editor shell call
Switch to using 'sequence'-delineated arguments given to the subprocess
run call to correctly handle whitespace.
Also check the output, so we exit if we have an error.
Test accordingly.
2025-11-29 18:52:43 +01:00

11 lines
396 B
Python

from pathlib import Path
from unittest.mock import Mock, patch
from topen import add_annotation, open_editor
def test_open_editor_escapes_shell():
"""Ensure filenames with spaces/metas do not allow shell injection."""
with patch("subprocess.run") as run_mock:
open_editor(Path("my note$1.txt"), "vim")
run_mock.assert_called_once_with(["vim", "my note$1.txt"], check=True)