Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quotes have to be escaped in "Show Curl" output #19

Closed
vasan-agrostar opened this issue Jun 14, 2024 · 4 comments · Fixed by agrostar/zzapi#11 or #21
Closed

quotes have to be escaped in "Show Curl" output #19

vasan-agrostar opened this issue Jun 14, 2024 · 4 comments · Fixed by agrostar/zzapi#11 or #21

Comments

@vasan-agrostar
Copy link
Collaborator

I have a parameter which has a quote in it. (I have to access this particular API: https://developer.freshdesk.com/api/#filter_tickets)

The Run Request runs fine, but when I click on "Show Curl", the quotes appear as is, thus terminating the open quote of the URL.

curl -X GET -H 'user-agent: zzAPI-vscode/2.3.0' -H 'authorization: Basic XXX' -k -i 'https://domain.freshdesk.com/api/v2/search/tickets?query=%22type%3A'Saathi%20Churn'%20AND%20created_at%3A'2024-05-31'%22&page=1'
@vasan-agrostar
Copy link
Collaborator Author

Also, can we drop the user-agent header? curl will send its own user-agent header, and we should respect that.

@Varun0157
Copy link
Collaborator

I understand the issue, but can you clarify what you mean by "quotes have to be escaped"? I interpret it to mean you want the quotes wrapping the headers, url, etc. to be escaped (\'...\' instead of '...') while creating the string, but I fail to see how that would help prevent cURL from misinterpreting the command, because the output command would still be the same, right?

The fix I see is just to replace the single quotes on creation with double quotes, but that may not be general enough.

@vasan-agrostar
Copy link
Collaborator Author

vasan-agrostar commented Jun 15, 2024

I think even \' won't work. BTW, it is the shell that interprets this, not curl. For the shell, anything within single quotes, including \ will be interpreted literally.

We could use double-quotes instead of single quotes, but that would mean lot of escaping. We will have to escape ", $, * at the minimum, because these have special meaning in the shell.

Even though it is not required to URL encode the single quote using %, we can do that and it will work. So replace all ' in the cURL command with %27 (even though the zzAPI request will have the single-quote as is).

Postman seems to do the same.

@Varun0157
Copy link
Collaborator

The node module replaces single quotes with %27, while the extension removes the zzAPI user-agent while calling constructCurl in the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants