postman-code-generators icon indicating copy to clipboard operation
postman-code-generators copied to clipboard

Wrong URL Encode

Open Farhan25 opened this issue 4 years ago • 5 comments

Describe the bug There seems to be a bug in URL encode for PHP generator (cURL, HTTP_Request2, pecl_http) and many others languages

To Reproduce fix the URL encode

Expected code snippet and corresponding request resource_id=sc-domain%253Aexample.com is wrong encoing the right one is resource_id=sc-domain%3Aexample.com

Screenshots image

Additional context the two URLs are different so the whole request would give two separate results.

Version of postman-code-generators/Postman app: I have the latest version for windows v7.36.1

Farhan25 avatar Dec 29 '20 15:12 Farhan25

The issue is that it is not replacing '%' sign correctly when it is passed as params in the Request body.

To Reproduce:

Pass a parameter with '%' as value to any key

The error:

Error is at line 111 of postman-code-generators/codegens/php-curl/lib/php-curl.js/

The encodeURI() function parses '%' as '%25' image

I would like to work on this issue. @abhijitkane

ShauryaAg avatar Jan 01 '21 15:01 ShauryaAg

Well I know what's the problem is, there is double encoding in there which cause the % to be encoded in the second time. I just mentioned it to be solved in the next update. Thanks for your work and if It's necessary I can help you guys :)

Farhan25 avatar Jan 01 '21 17:01 Farhan25

@Farhan25 Can you share the exact url that you are passing to postman? The one without any encoding applied.

webholik avatar Jan 03 '21 09:01 webholik

@webholik In that case, one cannot just copy any URL (say from chrome's URL bar), and paste it in Postman's URL Field.

I have made a PR #437 that fixes this issue. Can you please review it? Thanks

ShauryaAg avatar Jan 03 '21 09:01 ShauryaAg

@ShauryaAg of course, here is a similar one: https://search.google.com/search-console/links?resource_id=sc-domain%3Aexample.com

the problem is encoding the percentage symbol in the second time (% is encoded as %25).

: => %3A %3A => %253A

Farhan25 avatar Jan 04 '21 16:01 Farhan25