Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add catch/reject for invalid redirect URLs #1395

Closed

Conversation

Abromeit
Copy link

@Abromeit Abromeit commented Nov 20, 2021

Purpose

HTTP responses with invalid URLs in the location header field resulted in an uncatchable exception (TypeError [ERR_INVALID_URL]: Invalid URL), even in "manual" redirect-handling mode.

This patch fixes the issue, invalid redirect targets are now rejected gracefully.

Changes

  • Add missing try/catch block around new URL(…) in request_.on('response', …) of src/index.js
  • Introduce new FetchError type "invalid-redirect"

Additional information

Real-world example to reproduce the problem: Location: http://


  • I updated ./docs/CHANGELOG.md with a link to this PR or Issue
  • I updated ./docs/v3-UPGRADE-GUIDE
  • I updated readme
  • I added unit test(s)

HTTP responses with invalid URLs in the location header field resulted in an uncatchable error. 
(`TypeError [ERR_INVALID_URL]: Invalid URL`)

Real-world example: `Location: http://`
@jimmywarting
Copy link
Collaborator

This is pretty much the same as #1387

This one also lacks a test for fetch(url, {redirect: 'manual'})

@Abromeit
Copy link
Author

True @ #1387 – I have no idea how i missed that ^^

@Abromeit Abromeit closed this Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants