From 68238e3db229ac472ee006e942624cfb7802dbdd Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Wed, 5 Nov 2025 08:51:04 +0100 Subject: [PATCH] Refines temp directory path validation Ensures accurate determination of whether a directory is a temporary directory by explicitly matching the full path or a subdirectory. This change prevents potential issues related to incorrect path comparisons, especially on Windows where path variations can occur. --- src/core/TempDirectoryManager.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/TempDirectoryManager.ts b/src/core/TempDirectoryManager.ts index f782ec9..b2b86ed 100644 --- a/src/core/TempDirectoryManager.ts +++ b/src/core/TempDirectoryManager.ts @@ -446,7 +446,13 @@ export class TempDirectoryManager { const tempImagesDir = normalizePath(path.join(pluginDir, PLUGIN_DIRS.TEMP_IMAGES)); const tempPandocDir = normalizePath(path.join(pluginDir, PLUGIN_DIRS.TEMP_PANDOC)); - return normalizedDirPath.startsWith(tempImagesDir) || - normalizedDirPath.startsWith(tempPandocDir); + const isImagesDir = + normalizedDirPath === tempImagesDir || + normalizedDirPath.startsWith(`${tempImagesDir}/`); + const isPandocDir = + normalizedDirPath === tempPandocDir || + normalizedDirPath.startsWith(`${tempPandocDir}/`); + + return isImagesDir || isPandocDir; } } \ No newline at end of file