[GH-ISSUE #2829] [bug]: query parameters are escaped implicitly #911

Closed
opened 2026-03-16 17:38:40 +03:00 by kerem · 23 comments
Owner

Originally created by @liudonghua123 on GitHub (Oct 27, 2022).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/2829

Originally assigned to: @maneeshms on GitHub.

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When I send a Get request with the following parameters(in bulk edit).

token: token_part1 token_part2
attrs: password%3Dabc

The actual request sent is url?token=token_part1+token_part2&attrs=password%253Dabc which is wrong for my server.

If I send the same Get request using postman, the actual request sent is url?token=token_part1%20token_part2&attrs=password%3Dabc which is correct for my server.

I found the problem code is around the following code.

github.com/hoppscotch/hoppscotch@dc80cc80e6/packages/hoppscotch-app/src/helpers/strategies/ExtensionStrategy.ts (L64-L70)

url=new URL("http://localhost")
url.searchParams.append('token','token_part1 token_part2')
url.searchParams.append('attrs','password%3Dabc')
console.info(url.toString()) // http://localhost/?token=token_part1+token_part2&attrs=password%253abc

url=new URL('http://localhost/?token=token_part1+token_part2&attrs=password%253abc')
console.info(url.searchParams.get('token')) // token_part1 token_part2
console.info(url.searchParams.get('attrs')) // password%3Dabc
console.info(decodeURI('http://localhost/?token=token_part1+token_part2&attrs=password%253abc')) // http://localhost/?token=token_part1+token_part2&attrs=password%3Dabc


See also https://developer.mozilla.org/en-US/docs/Web/API/URL/toString, https://javascript.info/url, https://url.spec.whatwg.org/#URL-stringification-behavior.

Steps to reproduce

  1. Go to Parameters tab, click Bulk edit.
  2. Fill with the following contents
token: token_part1 token_part2
attrs: password%3Dabc
  1. Click Send button to make the request.

Environment

Release

Version

Cloud

Originally created by @liudonghua123 on GitHub (Oct 27, 2022). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/2829 Originally assigned to: @maneeshms on GitHub. ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior When I send a `Get` request with the following parameters(in bulk edit). ``` token: token_part1 token_part2 attrs: password%3Dabc ``` The actual request sent is `url?token=token_part1+token_part2&attrs=password%253Dabc` which is wrong for my server. If I send the same `Get` request using postman, the actual request sent is `url?token=token_part1%20token_part2&attrs=password%3Dabc` which is correct for my server. I found the problem code is around the following code. https://github.com/hoppscotch/hoppscotch/blob/dc80cc80e6e9c02c41a0754dfa7868f7f102964a/packages/hoppscotch-app/src/helpers/strategies/ExtensionStrategy.ts#L64-L70 ```js url=new URL("http://localhost") url.searchParams.append('token','token_part1 token_part2') url.searchParams.append('attrs','password%3Dabc') console.info(url.toString()) // http://localhost/?token=token_part1+token_part2&attrs=password%253abc url=new URL('http://localhost/?token=token_part1+token_part2&attrs=password%253abc') console.info(url.searchParams.get('token')) // token_part1 token_part2 console.info(url.searchParams.get('attrs')) // password%3Dabc console.info(decodeURI('http://localhost/?token=token_part1+token_part2&attrs=password%253abc')) // http://localhost/?token=token_part1+token_part2&attrs=password%3Dabc ``` See also https://developer.mozilla.org/en-US/docs/Web/API/URL/toString, https://javascript.info/url, https://url.spec.whatwg.org/#URL-stringification-behavior. ### Steps to reproduce 1. Go to `Parameters` tab, click `Bulk edit`. 2. Fill with the following contents ``` token: token_part1 token_part2 attrs: password%3Dabc ``` 3. Click `Send` button to make the request. ### Environment Release ### Version Cloud
kerem 2026-03-16 17:38:40 +03:00
Author
Owner

@liudonghua123 commented on GitHub (Oct 27, 2022):

If I send the request with the following parameters.

token: token_part1 token_part2
attrs: password%3Dabc

Then the request is ok. It seems the space in url query string can be encode/escape as + or %20. Both of them work.

So maybe the request works in postman is because it checks whether some spaces are in the parameters or not, encodeURIComponent is called if some spaces are included. It will NOT encode/escape the parameters.

A config setting toggles the encode/escape functionality would be nice for test purposes.

<!-- gh-comment-id:1293112601 --> @liudonghua123 commented on GitHub (Oct 27, 2022): If I send the request with the following parameters. ``` token: token_part1 token_part2 attrs: password%3Dabc ``` Then the request is ok. It seems the space in url query string can be `encode/escape` as `+` or `%20`. Both of them work. So maybe the request works in postman is because it checks whether some spaces are in the parameters or not, `encodeURIComponent` is called if some spaces are included. It will NOT `encode/escape` the parameters. A config setting toggles the `encode/escape` functionality would be nice for test purposes.
Author
Owner

@liudonghua123 commented on GitHub (Oct 27, 2022):

The space character is the only character that has two acceptable URL-encoded representations. Instead of encoding a space as “%20,” you can use the plus sign reserved character to represent a space.

https://www.fullhost.com/blog/what-does-20-mean-in-a-web-address/

url1=new URL('http://localhost/?token=token_part1+token_part2&attrs=password%253abc')
url2=new URL('http://localhost/?token=token_part1%20token_part2&attrs=password%253abc')
console.info(url1.searchParams.get('token')) // token_part1 token_part2
console.info(url2.searchParams.get('token')) // token_part1 token_part2
console.info(url1.searchParams.get('token') === url2.searchParams.get('token')) // true
<!-- gh-comment-id:1293129274 --> @liudonghua123 commented on GitHub (Oct 27, 2022): > The space character is the only character that has two acceptable URL-encoded representations. Instead of encoding a space as “%20,” you can use the plus sign reserved character to represent a space. https://www.fullhost.com/blog/what-does-20-mean-in-a-web-address/ ```js url1=new URL('http://localhost/?token=token_part1+token_part2&attrs=password%253abc') url2=new URL('http://localhost/?token=token_part1%20token_part2&attrs=password%253abc') console.info(url1.searchParams.get('token')) // token_part1 token_part2 console.info(url2.searchParams.get('token')) // token_part1 token_part2 console.info(url1.searchParams.get('token') === url2.searchParams.get('token')) // true ```
Author
Owner

@AndrewBastin commented on GitHub (Oct 27, 2022):

Since the current implementation is correct according to the spec, we are prioritizing this as a low priority issue.

PR contributions for implementing the toggle for considering both ways are welcome in the meantime :)

<!-- gh-comment-id:1293980390 --> @AndrewBastin commented on GitHub (Oct 27, 2022): Since the current implementation is correct according to the spec, we are prioritizing this as a low priority issue. PR contributions for implementing the toggle for considering both ways are welcome in the meantime :)
Author
Owner

@Rathan-Naik commented on GitHub (Jan 1, 2023):

Just getting started on contributions @AndrewBastin I can work on implementing the toggle.

<!-- gh-comment-id:1368508168 --> @Rathan-Naik commented on GitHub (Jan 1, 2023): Just getting started on contributions @AndrewBastin I can work on implementing the toggle.
Author
Owner

@AndrewBastin commented on GitHub (Jan 6, 2023):

Cool @Rathan-Naik, please do let me know if you need any help/guidance.

Assigning the task to you.

<!-- gh-comment-id:1372967783 --> @AndrewBastin commented on GitHub (Jan 6, 2023): Cool @Rathan-Naik, please do let me know if you need any help/guidance. Assigning the task to you.
Author
Owner

@Ahishekoza commented on GitHub (Jan 28, 2023):

Hello @AndrewBastin,
I would like to contribute to this issue

<!-- gh-comment-id:1407306491 --> @Ahishekoza commented on GitHub (Jan 28, 2023): Hello @AndrewBastin, I would like to contribute to this issue
Author
Owner

@JManan commented on GitHub (Jun 24, 2023):

hey @AndrewBastin i would like to contribute to this issue. Please let me do it.

<!-- gh-comment-id:1605702626 --> @JManan commented on GitHub (Jun 24, 2023): hey @AndrewBastin i would like to contribute to this issue. Please let me do it.
Author
Owner

@AndrewBastin commented on GitHub (Jun 26, 2023):

@JManan sure.

<!-- gh-comment-id:1606597688 --> @AndrewBastin commented on GitHub (Jun 26, 2023): @JManan sure.
Author
Owner

@Pheonix075 commented on GitHub (Aug 7, 2023):

hey @AndrewBastin I would like to contribute to this issue.give me a chance

<!-- gh-comment-id:1668271452 --> @Pheonix075 commented on GitHub (Aug 7, 2023): hey @AndrewBastin I would like to contribute to this issue.give me a chance
Author
Owner

@VinayakSingh2001 commented on GitHub (Aug 18, 2023):

Hey @tejakummarikuntla I would like to work on this, can you please assign this to me !!

<!-- gh-comment-id:1683350166 --> @VinayakSingh2001 commented on GitHub (Aug 18, 2023): Hey @tejakummarikuntla I would like to work on this, can you please assign this to me !!
Author
Owner

@tejakummarikuntla commented on GitHub (Aug 18, 2023):

Sorry @VinayakSingh2001 , I don't think I can help you here. Did you mean to tag @AndrewBastin ?

<!-- gh-comment-id:1683454581 --> @tejakummarikuntla commented on GitHub (Aug 18, 2023): Sorry @VinayakSingh2001 , I don't think I can help you here. Did you mean to tag @AndrewBastin ?
Author
Owner

@yashnirmal commented on GitHub (Sep 14, 2023):

Hey @tejakummarikuntla is the issue still open?

<!-- gh-comment-id:1719640876 --> @yashnirmal commented on GitHub (Sep 14, 2023): Hey @tejakummarikuntla is the issue still open?
Author
Owner

@liudonghua123 commented on GitHub (Sep 15, 2023):

No PR currently?

I suggest to add a configuration named Encode(Encode the query params, three options provided, enable means always encode the params, disable means do not encode the params and auto means encode the params which contain some common special characters need to encode).

And only two group of settings available now, one for Theme, another for Interceptor. Maybe a new group named Other is a good idea for this new Encode setting.

<!-- gh-comment-id:1720785892 --> @liudonghua123 commented on GitHub (Sep 15, 2023): No PR currently? I suggest to add a configuration named Encode(Encode the query params, three options provided, enable means always encode the params, disable means do not encode the params and auto means encode the params which contain some common special characters need to encode). And only two group of settings available now, one for `Theme`, another for `Interceptor`. Maybe a new group named `Other` is a good idea for this new `Encode` setting.
Author
Owner

@meetdhanani17 commented on GitHub (Oct 2, 2023):

it is need to add a toggle like space as %20 or + or i change to direct convert space as %20?

<!-- gh-comment-id:1742448849 --> @meetdhanani17 commented on GitHub (Oct 2, 2023): it is need to add a toggle like space as %20 or + or i change to direct convert space as %20?
Author
Owner

@maneeshms commented on GitHub (Dec 28, 2023):

@tejakummarikuntla If this issue is still open and no PR raised yet, i would like to give a try.

<!-- gh-comment-id:1870781368 --> @maneeshms commented on GitHub (Dec 28, 2023): @tejakummarikuntla If this issue is still open and no PR raised yet, i would like to give a try.
Author
Owner

@liyasthomas commented on GitHub (Dec 28, 2023):

Assigning to @maneeshms.

<!-- gh-comment-id:1870793295 --> @liyasthomas commented on GitHub (Dec 28, 2023): Assigning to @maneeshms.
Author
Owner

@TheDynamicPunk commented on GitHub (May 16, 2024):

Hey @liyasthomas it's been a while since there has been some activity on this thread. If you've still not received any PR's for this, maybe I can take a look with some assistance from you?

<!-- gh-comment-id:2115449812 --> @TheDynamicPunk commented on GitHub (May 16, 2024): Hey @liyasthomas it's been a while since there has been some activity on this thread. If you've still not received any PR's for this, maybe I can take a look with some assistance from you?
Author
Owner

@Vaibhav-tech22 commented on GitHub (Jul 25, 2024):

Hey @liyasthomas, I see there are no activities on this bug. If no PRs have been raised in this matter. I would like to give it a try. Thanks.

<!-- gh-comment-id:2250873856 --> @Vaibhav-tech22 commented on GitHub (Jul 25, 2024): Hey @liyasthomas, I see there are no activities on this bug. If no PRs have been raised in this matter. I would like to give it a try. Thanks.
Author
Owner

@mohitsourav7 commented on GitHub (Sep 13, 2024):

Hi @AndrewBastin I see there are no activities on this bug .If you still haven't received any PR yet. I would like to give it a try

Regards

<!-- gh-comment-id:2348160298 --> @mohitsourav7 commented on GitHub (Sep 13, 2024): Hi @AndrewBastin I see there are no activities on this bug .If you still haven't received any PR yet. I would like to give it a try Regards
Author
Owner

@satwikkini-01 commented on GitHub (Oct 2, 2024):

Hello Mr @AndrewBastin , even I would like to give a try to solve this issue.
This will be my first open source contribution :)

<!-- gh-comment-id:2389481767 --> @satwikkini-01 commented on GitHub (Oct 2, 2024): Hello Mr @AndrewBastin , even I would like to give a try to solve this issue. This will be my first open source contribution :)
Author
Owner

@AndrewBastin commented on GitHub (Oct 7, 2024):

@satwikkini-01 @mohitsourav7 if you are interested in opening a PR, feel free to do so, you do not need to wait on an assignment : )

<!-- gh-comment-id:2397175032 --> @AndrewBastin commented on GitHub (Oct 7, 2024): @satwikkini-01 @mohitsourav7 if you are interested in opening a PR, feel free to do so, you do not need to wait on an assignment : )
Author
Owner

@Pranay-Pandey commented on GitHub (Oct 7, 2024):

Hey, @AndrewBastin
I have raised a PR, with the changes suggested by @liudonghua123 .
But with these changes it seems the encoding takes place twice.
image
Any suggestions?

<!-- gh-comment-id:2397912609 --> @Pranay-Pandey commented on GitHub (Oct 7, 2024): Hey, @AndrewBastin I have raised a PR, with the changes suggested by @liudonghua123 . But with these changes it seems the encoding takes place twice. ![image](https://github.com/user-attachments/assets/eb3f2f38-4525-419c-9605-2907ee0a3f3a) Any suggestions?
Author
Owner

@jamesgeorge007 commented on GitHub (Nov 1, 2024):

#4412 Released in v2024.10.0.

<!-- gh-comment-id:2452307020 --> @jamesgeorge007 commented on GitHub (Nov 1, 2024): #4412 Released in [v2024.10.0](https://github.com/hoppscotch/hoppscotch/releases/tag/2024.10.0).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#911
No description provided.