fix: handle drive root paths in image directory security check#301
Merged
fix: handle drive root paths in image directory security check#301
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--image-diris a Windows drive root (e.g.,E:\,D:\), the path already ends with a separator. The security check appended anotherpath.sep, creating a double-separator prefix (E:\\) that never matched any resolved path — rejecting all validlocalPathvalues.baseDiralready ends with a separator before appending one.Closes #300
Test plan
accepts valid path when imageDir is a drive root— usespath.resolve("/")as the image dir and verifies the path check passes