Use hostname for netrc instead split netloc
This patch uses the "hostname" attribute from the parsed url to get the host, instead of trying to calculate the host from netloc that can produce errors when "http://username:[email protected]" format is used.
This should fix the security issue reported here: CVE-2024-47081: Netrc credential leak in PSF requests library
@danigm Thanks! The new test is failing on Windows, can you take a peek?
Can you please rebase as well?
I've fixed the windows failure and rebased, so now this patch just adds a new test for netrc because the code fix was added in a different pr: https://github.com/psf/requests/pull/6965
An example of this vulnerability is available with this intentionally exploitable site, as documented here, https://www.openwall.com/lists/oss-security/2025/06/03/11