Skip to content

Commit

Permalink
fix(curl,shell): shell quoting on @file
Browse files Browse the repository at this point in the history
  • Loading branch information
llimllib committed Mar 21, 2024
1 parent ebc85d3 commit e070f56
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/targets/shell/curl/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,16 @@ export const curl: Client<CurlOptions> = {
case 'multipart/form-data':
postData.params?.forEach(param => {
let post = '';
// If the parameter is a filename, we want to put shell quotes around
// it rather than URL quoting it. Curl wants `file='@img copy.jpg'`
// not `file=@img%20copy.jpg`, which it will fail to find
if (param.fileName) {
post = `${param.name}=@${param.fileName}`;
post = `${param.name}='@${param.fileName}'`;
} else {
post = `${param.name}=${param.value}`;
post = quote(`${param.name}=${param.value}`);
}

push(`${arg('form')} ${quote(post)}`);
push(`${arg('form')} ${post}`);
});
break;

Expand Down

0 comments on commit e070f56

Please sign in to comment.