-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 an issue with URL encoding on cURL imports #5006
Conversation
Should be resolved by latest commit on my branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
fixes an issue where application/x-www-form-urlencoded curl body parameters are left URL encoded when being imported, causing them to be double-encoded (for example body parameters that contain an encoded "=" were imported as "%3D" which would be sent as "%253D" rather than just "%3D")
they are now double-encoded so when they get decoded they will return to what insomnia expects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a sticky wicket, this one is. recently we had something similar in httpsnippet to deal with Kong/httpsnippet#198
cURL treats -data
as being raw data but insomnia's curl importer parses it as form data if the content type is set to application/x-www-form-urlencoded
- and insomnia will internally url encode the data that is input here, so if it is already url encoded it will encode it twice. the solution of encoding -data-urlencode
arguments may seem a bit weird, but you can interleave -data
and -data-urlencode
so it needs to be normalized in some form ahead of time and this seems to be the way that makes the most sense.
this should make our handling of -data
and -data-urlencode
correct so that the cURL importer is able to correctly construct more request bodies.
@johnwchadwick and I wrote some tests for the preexisting behavior in 43556c1 and then updated the tests in 714a6b2 to reflect the new changes this PR brought about
As a future step, I think it'd be nice to fall back to raw text body for the request in the event that the cURL body cannot be correctly parsed as form data. (Example scenarios: |
Fixes an issue where
application/x-www-form-urlencoded
cURL body parameters are left URL encoded when being imported, causing them to be double-encoded (for example, body parameters that contain an encoded=
were imported as%3D
, which would be sent as%253D
rather than just%3D
).This fix was implemented by using
decodeURIComponent
on the name/value pair since the insomnia form body expects it to be decoded and encodes the values when they are sent.changelog(Fixes): Fixed an issue with cURL imports that caused URL-encoded parameters to be encoded twice