From a71b20e9ba26ce91e71ff3feb864aac8ba121c62 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Sat, 8 Nov 2025 19:05:46 +0100 Subject: [PATCH] Preserves absolute paths in SecurityUtils Updates path normalization to maintain absolute paths, aligning with SettingsTab storage logic. Enhances security by ensuring consistent path handling and preventing path traversal. Relates to issue: obsidian-bot-review branch --- src/core/SecurityUtils.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core/SecurityUtils.ts b/src/core/SecurityUtils.ts index c623687..68d4eb1 100644 --- a/src/core/SecurityUtils.ts +++ b/src/core/SecurityUtils.ts @@ -116,9 +116,10 @@ export class SecurityUtils { if (!outputFolder || typeof outputFolder !== 'string') { return false; } - - // Normalize and resolve the path to detect traversal attempts - const normalizedPath = path.normalize(outputFolder.trim()); + + // Normalize path, but preserve absolute paths (mirrors SettingsTab storage logic) + const trimmed = outputFolder.trim(); + const normalizedPath = path.isAbsolute(trimmed) ? trimmed : path.normalize(trimmed); // Check for path traversal attempts if (normalizedPath.includes('..') || @@ -280,8 +281,10 @@ export class SecurityUtils { if (!outputFolder || typeof outputFolder !== 'string') { return 'Output folder is required'; } - - const normalizedPath = path.normalize(outputFolder.trim()); + + // Normalize path, but preserve absolute paths (mirrors SettingsTab storage logic) + const trimmed = outputFolder.trim(); + const normalizedPath = path.isAbsolute(trimmed) ? trimmed : path.normalize(trimmed); if (normalizedPath.includes('..')) { return 'Path traversal attempts (..) are not allowed';