Skip to content

Commit a490544

Browse files
malmelooWhyNotHugo
authored andcommitted
Do not load netrc config files
1 parent 688d6f9 commit a490544

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

vdirsyncer/http.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from __future__ import annotations
22

33
import logging
4+
import os
5+
import platform
46
import re
57
from abc import ABC, abstractmethod
68
from base64 import b64encode
@@ -17,6 +19,13 @@
1719
logger = logging.getLogger(__name__)
1820
USERAGENT = f"vdirsyncer/{__version__}"
1921

22+
# 'hack' to prevent aiohttp from loading the netrc config,
23+
# but still allow it to read PROXY_* env vars.
24+
# Otherwise, if our host is defined in the netrc config,
25+
# aiohttp will overwrite our Authorization header.
26+
# https://github.com/pimutils/vdirsyncer/issues/1138
27+
os.environ["NETRC"] = "NUL" if platform.system() == "Windows" else "/dev/null"
28+
2029

2130
class AuthMethod(ABC):
2231
def __init__(self, username, password):

0 commit comments

Comments
 (0)