insomnia
insomnia copied to clipboard
Query can't handle number after %
Expected Behavior
The URI encoding of % isn't handle correct when a number is entered.
http://localhost?test=%30%
should pass the query test
with value %30%
or
http://localhost?test=%2530%25
should pass the query test
with value %2530%25
Actual Behavior
Reproduction Steps
- Create a new GET request
- Go to Query Tab
- Enter a
test
in New name field - Enter
%30%
in New value field - Url in preview turns into
0%25
Is there an existing issue for this?
- [X] I have searched the issue tracker for this problem.
Additional Information
curl http://localhost?test=%30%
and curl http://localhost?test=%2530%25
both send the correct
I found this post stating the same issue I'm experiencing:
https://github.com/Kong/insomnia/issues/605#issuecomment-825546206
Insomnia Version
v2022.3.0
What operating system are you using?
macOS
Operating System Version
macOS Monterey Version 12.3.1
Installation method
insomina.rest
Last Known Working Insomnia version
No response
Hi @Bert210 thanks for reporting this!
By any chance, are you still able to reproduce this issue on our latest release, 2022.4.0?
Hey @filfreire,
Sorry for the late reply. I just tested it with version 2022.4.3.
Version: Insomnia 2022.4.2
Build date: 6/22/2022
OS: Darwin x64 21.4.0
Electron: 18.1.0
Node: 16.13.2
V8: 10.0.139.15-electron.0
Architecture: x64
And it still occurs i've attached a current screenshot.
Thank you for checking this @Bert210!
We'll update you here as soon as there's any news.
This is even more weird:
%30%
becomes 0%25
%2530%
becomes %30%25
%252530%
becomes %2530%25
So, it seems to be parsed twice? So, can you either fully encode it directly or not encode it at all, please? Or perhaps make those options a toggle?
(Forget my previous replies, I deleted them, I misunderstood the problem.)
I seems that the real problem is that sometimes it doens't encode, sometimes it even decodes. Examples:
- % => %25 (correct)
- %2 => %252 (correct)
- %25 => %25 (should be %2525 - maybe it guesses that input is already url encoded, a feature that is unwanted for me)
- %25% => %25%25 (should be %2525%25 - this looks like some weird mixed mode that assumes the string is partially url encoded??)
- %3 => %253 (correct)
- %30 => 0 (should be %2530 - now it suddenly decodes - a third mode??)
- %30% => 0%25 (should be %2530%25 - so it decodes and encodes???)
I've been doing some more digging.
Insomnia tries to auto-detect if your parameters already encoded. Some people finds this nice, other people thinks this is unnecessary and unpredictable. Maybe it should be an option?
The point where it gets really complicated is that it tries to support mixes, which makes it very unpredictable.
For example %25%35% becomes %255%25:
- %25 => %25 // Untouched
- %35 => 5 // Decoded
- % => %24 // Encoded
Other weird behaviors includes:
- If the URL has a query string "a=%2530%25" and I click "Import form URL", nothing happens, unlike most other strings.
- To generate a URL with the query string "a=%2530%25", I must use input like "a: %252530%25", which is a puzzle I don't want to have to do.
I think that this is a fundamental issue with this feature. There will always be a lot of near-unpredictable edge-cases with this kind of magic.
I have two alternative suggestions to add to OP's idea of using backslash-escaping:
- Don't do any magic at all. Just assume input is plaintext and encode it.
- Analyse the complete input string, and decide if it's already encoded or not. Then either encode the entire string, or pass it as is.