Befunde der Abschlussprüfung behoben

This commit is contained in:
Rsclub2_2 committed 2026-11-15 03:02:45 +01:00
1 parent 7bd3498501
commit 95a23c0e45
23 files changed
+651 -44

No files matched your search

+7 -3
View File
@@ -11,14 +11,18 @@ _ADDRESS = re.compile(r"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")
_ANGLE_ADDRESS = re.compile(r"<([^<>\s]+@[^<>\s]+)>")
def _allowed(address: str, domains) -> bool:
return address.rsplit("@", 1)[-1] in {d.lower() for d in domains}
def _allowed(address: str, entries) -> bool:
"""An entry is a domain (every address of it is allowed) or a full address (exactly that one is allowed).
Public mail providers belong in the list as full addresses: a domain entry for them would allow strangers."""
entries = {e.strip().lower() for e in entries}
return address in entries or address.rsplit("@", 1)[-1] in entries # a domain entry never contains "@"
def original_recipient(text: str, forwarder: str, allowed_domains) -> str:
"""First allowed address from the quoted 'To:'/'An:' lines, else the forwarder, else ''.
Only addresses of allowed domains are ever returned: the agent types this address into foreign pages."""
allowed_domains holds domains and full addresses (see _allowed). Only allowed addresses are ever returned:
the agent types this address into foreign pages."""
plain = BeautifulSoup(_ANGLE_ADDRESS.sub(r"[\1]", text or ""), "html.parser").get_text("\n")
for line in _HEADER.findall(plain):
for address in _ADDRESS.findall(line):