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

jdarling picture jdarling  路  3Comments

svlungade picture svlungade  路  3Comments

IgorDePaula picture IgorDePaula  路  3Comments

victor0402 picture victor0402  路  4Comments

Guymestef picture Guymestef  路  3Comments