Skip to content

fix: handle drive root paths in image directory security check#301

Merged
GLips merged 2 commits intomainfrom
fix/drive-root-path-validation
Mar 20, 2026
Merged

fix: handle drive root paths in image directory security check#301
GLips merged 2 commits intomainfrom
fix/drive-root-path-validation

Conversation

@GLips
Copy link
Copy Markdown
Owner

@GLips GLips commented Mar 20, 2026

Summary

  • When --image-dir is a Windows drive root (e.g., E:\, D:\), the path already ends with a separator. The security check appended another path.sep, creating a double-separator prefix (E:\\) that never matched any resolved path — rejecting all valid localPath values.
  • Fixed by checking whether baseDir already ends with a separator before appending one.
  • Added a test case covering the drive-root scenario.

Closes #300

Test plan

  • New test: accepts valid path when imageDir is a drive root — uses path.resolve("/") as the image dir and verifies the path check passes
  • All existing path validation tests continue to pass
  • Type check and lint clean

GLips added 2 commits March 20, 2026 07:57
When --image-dir is a drive root (e.g., E:\), the path already ends
with a separator. Appending another separator created a double-separator
prefix that never matched resolved paths, rejecting all valid localPath
values.

Closes #300
The stub FigmaService was an empty object, so tests that passed path
validation immediately threw on downloadImages, fell into the catch
block, and only "passed" via a weak negative assertion. Give the stub a
downloadImages that returns [] so the handler completes normally, and
assert isError is undefined.
@GLips GLips merged commit 9f32616 into main Mar 20, 2026
1 check passed
medyas pushed a commit to YassineValue/Figma-Context-MCP that referenced this pull request Mar 22, 2026
- Replace sharp (native C++) with jimp (pure JS) for image processing
- Add --image-dir/IMAGE_DIR config for controlling image download path
- Skip jimp processing for SVGs, prevent image-fill collapse in SVG containers
- Handle drive root paths in image directory security check (Windows)
- Add defense-in-depth path check in downloadFigmaImage
- Add filenameSuffix regex validation
compassalessandrolorenz pushed a commit to compassalessandrolorenz/Figma-Context-MCP-AIR that referenced this pull request Mar 25, 2026
…#301)

* fix: handle drive root paths in image directory security check

When --image-dir is a drive root (e.g., E:\), the path already ends
with a separator. Appending another separator created a double-separator
prefix that never matched resolved paths, rejecting all valid localPath
values.

Closes GLips#300

* test: fix path-validation stubs so happy-path tests assert success

The stub FigmaService was an empty object, so tests that passed path
validation immediately threw on downloadImages, fell into the catch
block, and only "passed" via a weak negative assertion. Give the stub a
downloadImages that returns [] so the handler completes normally, and
assert isError is undefined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--image-dir with drive root path fails due to double path separator in security check

1 participant