Skip to content

Commit d107a3b

Browse files
committed
fix: validate create action path stays inside workspace folder
Consistent with how replace, tidy, doc set, and doc get actions validate paths via toWorkspaceFileTarget. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent bdd17f9 commit d107a3b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/commands/quickActions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ export async function runQuickAction(): Promise<void> {
239239
}
240240

241241
const absolutePath = path.resolve(folder.uri.fsPath, relativePath.trim());
242+
const relative = path.relative(folder.uri.fsPath, absolutePath);
243+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) {
244+
await vscode.window.showWarningMessage("File path must stay inside the workspace folder.");
245+
return;
246+
}
247+
242248
const action = buildCreateQuickAction(absolutePath);
243249
const result = await executePatchloom(binaryPath, action.args, folder.uri.fsPath);
244250

0 commit comments

Comments
 (0)