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.
This commit is contained in:
AlexKucera committed 2025-11-05 08:51:04 +01:00
1 parent c7b9a8b5b8
commit 68238e3db2
1 file changed
+8 -2
+8 -2
View File
@@ -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;
}
}