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

Fix parsing urlencoded pairs with empty values. #6980

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

adamroyle
Copy link
Contributor

There is a bug with parsing curl statements with empty values. This fixes the bug and adjusts the tests to expected behavior.

@CLAassistant
Copy link

CLAassistant commented Jan 11, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@filfreire filfreire force-pushed the fix-curl-parse-data-raw branch from c67559f to a28d283 Compare March 27, 2024 15:22
@filfreire
Copy link
Member

Hi @adamroyle thanks for submitting this! We're eager to help you get this into a merged state.

While I was testing this PR out locally I've found some cases where we will still not properly render urlencoded pairs. Can you provide an example you used for testing this PR?

@adamroyle
Copy link
Contributor Author

I'm just using a simple example:

curl 'http://localhost/' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-raw 'param1=&param2=&param3=value'

As an aside, however, I found another issue where Bash-style ANSI-C quoted strings (eg. --data-raw $'....') were not decoded properly. Google Chrome's "Copy as cURL" feature uses them for JSON strings that contain special chars.

eg.

curl 'http://localhost/' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  --data-raw $'{"name":"O\'Reilly"}'

I spent a while trying to get it to work but ran into too many issues (mainly with general shell parsing libraries not implementing Bash-style quotes), and instead built a parser for "Copy as fetch (Node.js)" instead which has been much more reliable.

@jackkav jackkav force-pushed the fix-curl-parse-data-raw branch from a28d283 to 1bdf78f Compare April 11, 2024 07:01
@jackkav jackkav merged commit 0a2187f into Kong:develop Apr 11, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants