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:
1 file changed
+8
-2
@@ -446,7 +446,13 @@ export class TempDirectoryManager {
|
|||||||
const tempImagesDir = normalizePath(path.join(pluginDir, PLUGIN_DIRS.TEMP_IMAGES));
|
const tempImagesDir = normalizePath(path.join(pluginDir, PLUGIN_DIRS.TEMP_IMAGES));
|
||||||
const tempPandocDir = normalizePath(path.join(pluginDir, PLUGIN_DIRS.TEMP_PANDOC));
|
const tempPandocDir = normalizePath(path.join(pluginDir, PLUGIN_DIRS.TEMP_PANDOC));
|
||||||
|
|
||||||
return normalizedDirPath.startsWith(tempImagesDir) ||
|
const isImagesDir =
|
||||||
normalizedDirPath.startsWith(tempPandocDir);
|
normalizedDirPath === tempImagesDir ||
|
||||||
|
normalizedDirPath.startsWith(`${tempImagesDir}/`);
|
||||||
|
const isPandocDir =
|
||||||
|
normalizedDirPath === tempPandocDir ||
|
||||||
|
normalizedDirPath.startsWith(`${tempPandocDir}/`);
|
||||||
|
|
||||||
|
return isImagesDir || isPandocDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user