From 1fa0cd42b746183c54fe477990c3157b3f249869 Mon Sep 17 00:00:00 2001 From: Jaen Saul Date: Mon, 12 Feb 2024 18:16:48 +0200 Subject: [PATCH] Fix cURL short -d option handling One of the code paths was not using the `arg()` helper. --- src/targets/shell/curl/client.ts | 2 +- src/targets/shell/curl/fixtures/short-options.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/targets/shell/curl/client.ts b/src/targets/shell/curl/client.ts index 015427550..d0ba163f0 100644 --- a/src/targets/shell/curl/client.ts +++ b/src/targets/shell/curl/client.ts @@ -139,7 +139,7 @@ export const curl: Client = { const encoded = encodeURIComponent(param.name); const needsEncoding = encoded !== unencoded; const name = needsEncoding ? encoded : unencoded; - const flag = binary ? '--data-binary' : `--data${needsEncoding ? '-urlencode' : ''}`; + const flag = binary ? '--data-binary' : needsEncoding ? '--data-urlencode' : arg('data'); push(`${flag} ${quote(`${name}=${param.value}`)}`); }); } else { diff --git a/src/targets/shell/curl/fixtures/short-options.sh b/src/targets/shell/curl/fixtures/short-options.sh index f2670d7b8..6f123f22f 100755 --- a/src/targets/shell/curl/fixtures/short-options.sh +++ b/src/targets/shell/curl/fixtures/short-options.sh @@ -1 +1 @@ -curl -X POST 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value' -H 'accept: application/json' -H 'content-type: application/x-www-form-urlencoded' -b 'foo=bar; bar=baz' --data foo=bar \ No newline at end of file +curl -X POST 'https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value' -H 'accept: application/json' -H 'content-type: application/x-www-form-urlencoded' -b 'foo=bar; bar=baz' -d foo=bar \ No newline at end of file