insomnia icon indicating copy to clipboard operation
insomnia copied to clipboard

fix: encoded value be decoded issue

Open ZxBing0066 opened this issue 8 months ago • 0 comments

Background

When users pass percent-encoded strings in the query parameters, the encoded characters will be decoded. E.g. %4E.

Root Cause

  1. smartEncodeUrl calls deconstructQueryStringToParams before buildQueryStringFromParams, deconstructQueryStringToParams always decodes the params, the original proposal I guess is to keep all the strings to be only encoded once. Although encodeURIComponent and decodeURIComponent are often thought of as complementary, they are not exact opposites. This is because decodeURIComponent will decode all percent-encoded sequences, whereas encodeURIComponent only encodes necessary characters.
  2. When there is a , in the string, it'll be decoded to %2C, which seems it cause issues before, so %2C will always be replaced with ,. But if there is %2C in the original input, we should consider it as %2C instead of ,.

Changes

  1. Add skipDecode to deconstructQueryStringToParams
  2. Use ignore param instead of replace all %2C to ,
  3. Remove unused whitespace replacement
  4. Fix some typos

Closes #975

ZxBing0066 avatar May 09 '25 06:05 ZxBing0066