[GH-ISSUE #1151] [Bug] Copy as cURL doesn't correctly escape single quotes in query string #1146

Open
opened 2026-03-03 19:48:44 +03:00 by kerem · 3 comments
Owner

Originally created by @gspiers on GitHub (Feb 18, 2022).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1151

Originally assigned to: @NghiaTranUIT on GitHub.

Proxyman version? (Ex. Proxyman 1.4.3)

3.1.0 (30100)

macOS Version? (Ex. mac 10.14)

12.2.1 (21D62)

Steps to reproduce

  1. Load a URL that has a single quote in it. As an example https://example.com/api/v0.4/paymentmethod?$skip=0&$filter=currency%20eq%20'USD'&$top=25 (that was copied from the capture in Proxyman)
  2. See URL loaded in Proxyman.
  3. Right click and select "Copy cURL"
  4. Paste into a terminal (I use iTerm)

Result:

curl 'https://example.com/api/v0.4/paymentmethod?$skip=0&$filter=currency%20eq%20'USD'&$top=25' \
-H 'Host: example.com' \
-H 'Connection: keep-alive' \
-H 'Accept: application/json' \
-H 'User-Agent: XXXX' \
-H 'Authorization: Bearer XXXX' \
-H 'Accept-Language: en-US,en;q=0.9' \
--proxy http://localhost:9090

Running the above will result in the URL being fetched without the single quotes. Copied URL as captured by Proxyman is https://example.com/api/v0.4/paymentmethod?$skip=0&$filter=currency%20eq%20USD&$top=25

Expected behavior

Single quotes should be escaped for the shell:

curl 'https://example.com/api/v0.4/paymentmethod?$skip=0&$filter=currency%20eq%20'\''USD'\''&$top=25' \
-H 'Host: example.com' \
-H 'Connection: keep-alive' \
-H 'Accept: application/json' \
-H 'User-Agent: XXXX' \
-H 'Authorization: Bearer XXXX' \
-H 'Accept-Language: en-US,en;q=0.9' \
--proxy http://localhost:9090

Thank you. Also wanted to say I really like Proxyman, very useful tool 👍

It's possible the software producing that query string should actually escape the single quote as %27 but I think the above should still work in any case.

Originally created by @gspiers on GitHub (Feb 18, 2022). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1151 Originally assigned to: @NghiaTranUIT on GitHub. ### Proxyman version? (Ex. Proxyman 1.4.3) 3.1.0 (30100) ### macOS Version? (Ex. mac 10.14) 12.2.1 (21D62) ### Steps to reproduce 1. Load a URL that has a single quote in it. As an example `https://example.com/api/v0.4/paymentmethod?$skip=0&$filter=currency%20eq%20'USD'&$top=25` (that was copied from the capture in Proxyman) 2. See URL loaded in Proxyman. 3. Right click and select "Copy cURL" 4. Paste into a terminal (I use iTerm) Result: ``` curl 'https://example.com/api/v0.4/paymentmethod?$skip=0&$filter=currency%20eq%20'USD'&$top=25' \ -H 'Host: example.com' \ -H 'Connection: keep-alive' \ -H 'Accept: application/json' \ -H 'User-Agent: XXXX' \ -H 'Authorization: Bearer XXXX' \ -H 'Accept-Language: en-US,en;q=0.9' \ --proxy http://localhost:9090 ``` Running the above will result in the URL being fetched without the single quotes. Copied URL as captured by Proxyman is `https://example.com/api/v0.4/paymentmethod?$skip=0&$filter=currency%20eq%20USD&$top=25` ### Expected behavior Single quotes should be escaped for the shell: ``` curl 'https://example.com/api/v0.4/paymentmethod?$skip=0&$filter=currency%20eq%20'\''USD'\''&$top=25' \ -H 'Host: example.com' \ -H 'Connection: keep-alive' \ -H 'Accept: application/json' \ -H 'User-Agent: XXXX' \ -H 'Authorization: Bearer XXXX' \ -H 'Accept-Language: en-US,en;q=0.9' \ --proxy http://localhost:9090 ``` Thank you. Also wanted to say I really like Proxyman, very useful tool 👍 It's possible the software producing that query string should actually escape the single quote as `%27` but I think the above should still work in any case.
Author
Owner

@NghiaTranUIT commented on GitHub (Feb 18, 2022):

Thanks. It's definitely a bug. I'm working on it and send you a beta asap 👍

<!-- gh-comment-id:1044356189 --> @NghiaTranUIT commented on GitHub (Feb 18, 2022): Thanks. It's definitely a bug. I'm working on it and send you a beta asap 👍
Author
Owner

@NghiaTranUIT commented on GitHub (Feb 18, 2022):

@gspiers please try this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_3.1.0_Fix_curl_with_single_quote.dmg

This build will escape the single quote 👍

curl 'https://httpbin.org/get?%24skip=0&%24filter=currency%20eq%20'\''USD'\''&%24top=25' \
-H 'Host: httpbin.org' \
-H 'User-Agent: insomnia/2021.7.2' \
-H 'Accept: */*' \
--proxy http://localhost:9090
proxyman curl
<!-- gh-comment-id:1044727453 --> @NghiaTranUIT commented on GitHub (Feb 18, 2022): @gspiers please try this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_3.1.0_Fix_curl_with_single_quote.dmg This build will escape the single quote 👍 ```bash curl 'https://httpbin.org/get?%24skip=0&%24filter=currency%20eq%20'\''USD'\''&%24top=25' \ -H 'Host: httpbin.org' \ -H 'User-Agent: insomnia/2021.7.2' \ -H 'Accept: */*' \ --proxy http://localhost:9090 ``` <img width="1404" alt="proxyman curl" src="https://user-images.githubusercontent.com/5878421/154714718-9b45c267-f2aa-4eec-8120-b5fb170f22a8.png">
Author
Owner

@gspiers commented on GitHub (Feb 18, 2022):

This build will escape the single quote

@NghiaTranUIT Amazing! Just tried it and it works perfectly. You've got yourself a very happy customer 😀

<!-- gh-comment-id:1044828617 --> @gspiers commented on GitHub (Feb 18, 2022): > This build will escape the single quote @NghiaTranUIT Amazing! Just tried it and it works perfectly. You've got yourself a very happy customer 😀
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#1146
No description provided.