Request: Missing unescape() from self._qs breaks requests with authentication

Created on 1 Jun 2015  ·  4Comments  ·  Source: request/request

GET requests with http basic authentication credentials such as "http://user:[email protected]" fail with error "self._qs.unescape is not a function".

This error occurs in request.js:

  if (self.uri.auth && !self.hasHeader('authorization')) {
    var uriAuthPieces = self.uri.auth.split(':').map(function(item) {return self._qs.unescape(item)})
    self.auth(uriAuthPieces[0], uriAuthPieces.slice(1).join(':'), true) 
  }

Changing Querystring.prototype.unescape to use the global unescape() or decodeURIComponent appears to resolve this issue.

Environment: Electron 0.27.2 (chrome 43)

Most helpful comment

I note that unescape is deprecated: (reference)
consequently self._qs.unescape(item) should be replaced by decodeURI(item)

All 4 comments

That might be related to https://github.com/request/request/pull/1600 but tbh I don't see how's that possible. I need more context, can you provide a short code example that reproduces that bug?

It seems that the "querystring" library supplied by Browserify does not include querystring.unescape and therefore this assignment doesn't work as expected.

Refs:
https://github.com/substack/node-browserify/issues/826
https://github.com/mike-spainhower/querystring/issues/4
https://github.com/Gozala/querystring/issues/6

I'm closing this issue as it does not appear to be caused by a bug in this library.

@andornaut did you find how to fix it on electron? i still get this error

I note that unescape is deprecated: (reference)
consequently self._qs.unescape(item) should be replaced by decodeURI(item)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Guymestef picture Guymestef  ·  3Comments

jasonxia23 picture jasonxia23  ·  3Comments

Aranir picture Aranir  ·  3Comments

codecowboy picture codecowboy  ·  3Comments

lupo9557 picture lupo9557  ·  3Comments