Skip to content

Fixes issue with semicolon in form data (CURL) #277

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

Merged
merged 3 commits into from
Oct 29, 2020

Conversation

someshkoli
Copy link
Contributor

fixes #257
Curl requires form data to be enclosed in double quotes if form data value contains semicolon or comma
image

This PR adds check for the above conditions and adds the following changes

  • adds check for semicolon and comma in form data
  • encloses form data value if semicolon/comma is present
  • Modifies sanitize function, adds follows
    • adds option to escape double quotes
    • adds option to escape back slash

 - adds check for semicolon and comma in form data
 - encloses form data value if semicolon/comma is present
 - Modifies sanitize function, adds follows
    - adds option to escape double quotes
    - adds option to escape back slash
 - encloses all form data value in double quotes
 - adds following options to sanitize funtion
   - excape backslash
   - escape double quotes
 - escapes \, " , from form data values
 - Modifies unit test to add quotes
@umeshp7
Copy link
Contributor

umeshp7 commented Jun 3, 2020

https://travis-ci.com/github/postmanlabs/postman-code-generators/builds/169343297#L5074
Newman test for formdata is failing.
Please make sure the changes you have done are correct and works in all cases.

Screenshot 2020-06-03 at 1 25 32 PM

Look at the value of "qu", it should simply be "\"b\"". Why are there so many backslashes and double quotes added there?

Curl requires form data to be enclosed in double quotes if form data value contains semicolon or comma

Where are we checking if semicolon and/or comma are present in form data?

According to the image you shared, the , and ; have to be wrapped around double quotes if it occurs in a filename. Not for all kinds formdata values.

@someshkoli
Copy link
Contributor Author

someshkoli commented Jun 3, 2020

If we do that it conflicts with " inside the form data.
Also if we do that, form data values having "test" result in false respose, it takes string which is only present inside the quotes and does not consider quotes as a part of string. And if we try to escape those we get a whole new response from the backend. I have tried and tested the above approach and all the cases works with this

Also the "qu" = .... Works perfectly on local it's device , it's just failing in ci

@someshkoli
Copy link
Contributor Author

someshkoli commented Jun 3, 2020

Where are we checking if semicolon and/or comma are present in form data?

That approach failed for strings containing " so had to enclose all the form data in double quotes

image
@umeshp7 ^

@webholik
Copy link
Contributor

Problem is that behavior of curl has changed in newer versions. Quoting for non-file data is not required in version 7.47.0 which is what CI runs and adding quotes breaks that build as then the output after running curl no longer matches the one in newmanResponses.json.

@umeshp7 umeshp7 merged commit 32e76dd into postmanlabs:develop Oct 29, 2020
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.

Curl request Fail when form-data have semicolond in it
3 participants