fix: skip URL entries in save_text_as_source to prevent Path() errors

When raw_text contains URLs (e.g. from wallabag_atom parser), split()
breaks them into fragments that Path() tries to read as local files.
This causes spurious "No such file" errors and random paths to be
accessed. Skip entries that look like URLs before checking Path.exists().

Fixes #1000
This commit is contained in:
zkksdk 2026-04-18 00:25:10 +08:00
parent d1136d74cb
commit 5e47e055a2

View File

@ -155,6 +155,9 @@ def save_text_as_source(raw_text: str, filename: str='{ts}-stdin.txt', out_dir:
referenced_texts = ''
for entry in raw_text.split():
# Skip URLs - Path() can't handle them and they aren't local files
if any(entry.startswith(s) for s in ('http://', 'https://', 'ftp://')):
continue
try:
if Path(entry).exists():
referenced_texts += Path(entry).read_text()