From d381cf74d51ada4a0c47944ba33bf8555c868bcc Mon Sep 17 00:00:00 2001 From: stumpylog <797416+stumpylog@users.noreply.github.com> Date: Wed, 5 Aug 2026 13:20:51 -0700 Subject: [PATCH] Sure, defense in depth against odd things --- src/documents/export/sinks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/documents/export/sinks.py b/src/documents/export/sinks.py index ef940ffca..43b666cbe 100644 --- a/src/documents/export/sinks.py +++ b/src/documents/export/sinks.py @@ -222,6 +222,10 @@ class DirectoryExportSink(ExportSink): def _finalize(self) -> None: if self._delete: for f in self._snapshot: + if not f.is_relative_to(self._target): # pragma: no cover + # Defense in depth: a symlink inside the export dir can + # resolve outside of it; never delete outside the target. + continue f.unlink() delete_empty_directories(f.parent, self._target)