fix: add root guard to dirname loops in extension discovery#14257
Open
mcanouil wants to merge 3 commits intoquarto-dev:mainfrom
Open
fix: add root guard to dirname loops in extension discovery#14257mcanouil wants to merge 3 commits intoquarto-dev:mainfrom
mcanouil wants to merge 3 commits intoquarto-dev:mainfrom
Conversation
Add filesystem root detection to two directory-traversal loops in
`src/extension/extension.ts` that hang indefinitely when processing
files at the filesystem root (e.g. `/mermaid.qmd` in Docker containers
with `WORKDIR /`).
`dirname("/")` returns `"/"`, so loops without a root guard never
terminate. Apply the same `nextDir === dir` pattern already used in
`src/project/project-context.ts`.
Closes quarto-dev#14254
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
d6d66d1 to
07deb8e
Compare
Verify that inputExtensionDirs terminates when projectDir is "/" instead of looping forever. Covers the fix for quarto-dev#14254.
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.
Two directory-traversal loops in
src/extension/extension.tshang indefinitely when the input file is at the filesystem root (e.g./mermaid.qmdin Docker containers withWORKDIR /), becausedirname("/")returns"/".Add the same
nextDir === dirroot guard already used insrc/project/project-context.tsto both loops: the extension directory walk ininputExtensionDirs()and the brand path resolution inreadExtension().I only added test for one of the two loops without guardtrails, i.e. "extension" lookup.
For the brand lookup, it requires a more heavy setup as the internals is "private" thus requires a full Quarto project setup with extension, etc.
As the pattern is very similar, not sure it is worth it.
Closes #14254