Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Handle redirects to invalid URLs that break the parser
Browse files Browse the repository at this point in the history
Cherry-pick 00526e2
  • Loading branch information
Terry Rogers authored and kevinvanrijn committed Dec 16, 2024
1 parent 92c8321 commit 84b8a60
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ Redirect.prototype.onResponse = function (response, callback) {
}

var uriPrev = request.uri
request.uri = urlParser.parse(redirectTo)
try {
request.uri = urlParser.parse(redirectTo)
} catch (e) {
return callback(new Error('Failed to parse url: ' + request.uri.href))
}

// handle the case where we change protocol from https to http or vice versa
if (request.uri.protocol !== uriPrev.protocol && self.allowInsecureRedirect) {
Expand Down

0 comments on commit 84b8a60

Please sign in to comment.