+ "diff_text": "diff --git a/src/requests/utils.py b/src/requests/utils.py\nindex 4d3039b200..d113a6ff3e 100644\n--- a/src/requests/utils.py\n+++ b/src/requests/utils.py\n@@ -231,7 +231,7 @@ def get_netrc_auth(url, raise_errors=False):\n try:\n _netrc = netrc(netrc_path).authenticators(host)\n- if _netrc:\n+ if _netrc and any(_netrc):\n # Return with login / password\n login_i = 0 if _netrc[0] else 1\n return (_netrc[login_i], _netrc[2])\ndiff --git a/tests/test_utils.py b/tests/test_utils.py\nindex f9a287af1b..c477c4089a 100644\n--- a/tests/test_utils.py\n+++ b/tests/test_utils.py\n@@ -170,6 +170,16 @@ def test_not_vulnerable_to_bad_url_parsing(self, tmp_path, monkeypatch):\n auth = get_netrc_auth(\"http://example.com:@evil.com/'\")\n assert auth is None\n\n+def test_empty_default_credentials_ignored(self, tmp_path, monkeypatch):\n+ \"\"\"Empty default credentials should not be returned.\"\"\"\n+ netrc_path = tmp_path / \".netrc\"\n+ monkeypatch.setenv(\"NETRC\", str(netrc_path))\n+ with open(netrc_path, \"w\") as f:\n+ f.write(\"machine example.com login user password pass\\ndefault\\n\")\n+\n+ auth = get_netrc_auth(\"http://httpbin.org/\")\n+ assert auth is None\n",
0 commit comments