diff --git a/src/targets/shell/curl/client.ts b/src/targets/shell/curl/client.ts index d0ba163f..54d65a5c 100644 --- a/src/targets/shell/curl/client.ts +++ b/src/targets/shell/curl/client.ts @@ -122,13 +122,16 @@ export const curl: Client = { 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; diff --git a/src/targets/shell/curl/fixtures/multipart-data.sh b/src/targets/shell/curl/fixtures/multipart-data.sh index 693fabf3..42d3d3f6 100755 --- a/src/targets/shell/curl/fixtures/multipart-data.sh +++ b/src/targets/shell/curl/fixtures/multipart-data.sh @@ -1,5 +1,5 @@ curl --request POST \ --url https://httpbin.org/anything \ --header 'content-type: multipart/form-data' \ - --form foo=@src/fixtures/files/hello.txt \ + --form foo='@src/fixtures/files/hello.txt' \ --form 'bar=Bonjour le monde' \ No newline at end of file diff --git a/src/targets/shell/curl/fixtures/multipart-file.sh b/src/targets/shell/curl/fixtures/multipart-file.sh index 5abea7b7..6ea03380 100755 --- a/src/targets/shell/curl/fixtures/multipart-file.sh +++ b/src/targets/shell/curl/fixtures/multipart-file.sh @@ -1,4 +1,4 @@ curl --request POST \ --url https://httpbin.org/anything \ --header 'content-type: multipart/form-data' \ - --form foo=@src/fixtures/files/hello.txt \ No newline at end of file + --form foo='@src/fixtures/files/hello.txt' \ No newline at end of file