Skip to content

fix: add root guard to dirname loops in extension discovery#14257

Open
mcanouil wants to merge 3 commits intoquarto-dev:mainfrom
mcanouil:fix/issue14254
Open

fix: add root guard to dirname loops in extension discovery#14257
mcanouil wants to merge 3 commits intoquarto-dev:mainfrom
mcanouil:fix/issue14254

Conversation

@mcanouil
Copy link
Copy Markdown
Collaborator

@mcanouil mcanouil commented Mar 23, 2026

Two directory-traversal loops in src/extension/extension.ts hang indefinitely when the input file is at the filesystem root (e.g. /mermaid.qmd in Docker containers with WORKDIR /), because dirname("/") returns "/".

Add the same nextDir === dir root guard already used in src/project/project-context.ts to both loops: the extension directory walk in inputExtensionDirs() and the brand path resolution in readExtension().

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

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
@posit-snyk-bot
Copy link
Copy Markdown
Collaborator

posit-snyk-bot commented Mar 23, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Verify that inputExtensionDirs terminates when projectDir is "/"
instead of looping forever. Covers the fix for quarto-dev#14254.
@mcanouil mcanouil self-assigned this Mar 23, 2026
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.

Rendering does not work when Quarto document is stored at /

2 participants