From d775daec609aabaa1948c8c181fc58e7cdc42927 Mon Sep 17 00:00:00 2001 From: "Mike A." Date: Tue, 17 Sep 2024 23:22:06 +0200 Subject: [PATCH] Do not load netrc config files --- vdirsyncer/http.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vdirsyncer/http.py b/vdirsyncer/http.py index 16c60aa5..9321abab 100644 --- a/vdirsyncer/http.py +++ b/vdirsyncer/http.py @@ -1,6 +1,8 @@ from __future__ import annotations import logging +import os +import platform import re from abc import ABC, abstractmethod from base64 import b64encode @@ -17,6 +19,13 @@ logger = logging.getLogger(__name__) USERAGENT = f"vdirsyncer/{__version__}" +# 'hack' to prevent aiohttp from loading the netrc config, +# but still allow it to read PROXY_* env vars. +# Otherwise, if our host is defined in the netrc config, +# aiohttp will overwrite our Authorization header. +# https://github.com/pimutils/vdirsyncer/issues/1138 +os.environ["NETRC"] = "NUL" if platform.system() == "Windows" else "/dev/null" + class AuthMethod(ABC): def __init__(self, username, password):