insomnia icon indicating copy to clipboard operation
insomnia copied to clipboard

Fix parsing urlencoded pairs with empty values.

Open adamroyle opened this issue 7 months ago • 2 comments

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

adamroyle avatar Jan 11 '24 04:01 adamroyle

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jan 11 '24 04:01 CLAassistant

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.

CLAassistant avatar Jan 11 '24 04:01 CLAassistant

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?

filfreire avatar Apr 02 '24 14:04 filfreire

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.

adamroyle avatar Apr 02 '24 23:04 adamroyle