insomnia icon indicating copy to clipboard operation
insomnia copied to clipboard

Query can't handle number after %

Open Bert210 opened this issue 2 years ago • 3 comments

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

Screen Shot 2022-05-26 at 6 14 12 PM

Screen Shot 2022-05-26 at 6 28 05 PM

Screen Shot 2022-05-26 at 6 28 33 PM

Reproduction Steps

  1. Create a new GET request
  2. Go to Query Tab
  3. Enter a test in New name field
  4. Enter %30% in New value field
  5. Url in preview turns into 0%25

Is there an existing issue for this?

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

Bert210 avatar May 26 '22 22:05 Bert210

Hi @Bert210 thanks for reporting this!

By any chance, are you still able to reproduce this issue on our latest release, 2022.4.0?

filfreire avatar Jun 15 '22 10:06 filfreire

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. Screen Shot 2022-07-11 at 11 37 11 AM

Bert210 avatar Jul 11 '22 15:07 Bert210

Thank you for checking this @Bert210!

We'll update you here as soon as there's any news.

filfreire avatar Jul 26 '22 13:07 filfreire

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?

TheNeoBurn avatar Mar 17 '23 11:03 TheNeoBurn

(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???)

myplacedk avatar Sep 01 '23 11:09 myplacedk

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:

  1. Don't do any magic at all. Just assume input is plaintext and encode it.
  2. 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.

myplacedk avatar Sep 04 '23 07:09 myplacedk