needle icon indicating copy to clipboard operation
needle copied to clipboard

Wrong cookie sending

Open Sergey-bhw opened this issue 7 years ago • 2 comments

I am trying to figure out some issue with cookies, maybe I'm doing something wrong. Seems like cookies going to the server with some extra escaped characters. Tested with headless browser, I can see through fiddler a sent cookie (correct one) like this:

auth=SI7yyDeeoZ1Orxz2UHdKyyVgaG6%2B57EaQxA%2B3sEKUSFD2pyinrL5MIQu234%2F89XZUrY6G3MtI8H09DLOcH7dAxTALm%2B06WP%2F;

after that I am saving all cookies from a headless browser and doing GET request:

needleOpts.cookies = mycooks; console.log(JSON.stringify(needleOpts.cookies)); needle.get(myurl, needleOpts, (err, res) => {

At this point console still shows correct cookies, but in the fiddler for next GET request I see my cookie was sent like this:

auth=SI7yyDeeoZ1Orxz2UHdKyyVgaG6%252B57EaQxA%252B3sEKUSFD2pyinrL5MIQu234%252F89XZUrY6G3MtI8H09DLOcH7dAxTALm%252B06WP%252F;

If you compare this auth cookies there is a extra characters after % symbol.

Edit: found a walkaround, just wrapping cookie values in decodeURIComponent when saving them.

Sergey-bhw avatar Feb 05 '18 12:02 Sergey-bhw

@SergeyYermak Good catch. Are you suggesting that we use decodeURIComponent by default?

tomas avatar Feb 13 '18 20:02 tomas

@tomas Well if it will not cause any issues with regular cookie usage. I'm facing this characters not so often in cookies. May be some config option will be better.

Sergey-bhw avatar Feb 13 '18 23:02 Sergey-bhw