fix(copy-as): emit shell-safe arguments in the curl and gRPCurl exporters (#593)

This commit is contained in:
Ngo Quoc Viet
2026-08-20 08:41:47 -07:00
committed by GitHub
parent cb295b7102
commit 388dd8815f
4 changed files with 67 additions and 5 deletions
+4 -1
View File
@@ -129,7 +129,10 @@ export async function convert(request: Partial<GrpcRequest>, allProtoFiles: stri
}
function quote(arg: string): string {
const escaped = arg.replace(/'/g, "\\'");
// A single-quoted POSIX string takes no escapes, so `\'` does not close it:
// the string ends one character early and the rest of the command is left
// dangling. Step out of the quotes, emit an escaped quote, step back in.
const escaped = arg.replace(/'/g, `'\\''`);
return `'${escaped}'`;
}