fix: Hostnamen normalisieren (Schema/Slash strippen) + freundlichere Nextcloud-Fehler

Bug: nextcloudhost mit https://-Präfix in CSV/GUI führte zu Doppel-Schema
(https://https://cloud.foo.de) und damit zu DNS-Fehler "host=https".

- models.clean_host() entfernt http(s):// und Trailing-Slash; Account
  ruft das im __post_init__ für plesk-/kerio-/nextcloudhost auf.
- NextcloudClient wickelt requests-Connection-Fehler in NextcloudError
  ein, damit die Log-Ausgabe lesbar bleibt statt HTTPSConnectionPool-Stacktrace.
- README: Hostname-Eingabe als tolerant dokumentiert; pleskhost-Pflicht
  im manual-Modus klarer (POP3-Sammler braucht es trotzdem).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-12 13:05:51 +02:00
parent dda5c746ce
commit b88c766dd6
3 changed files with 39 additions and 10 deletions
+19
View File
@@ -2,6 +2,19 @@ from dataclasses import dataclass, field
from typing import List, Optional
def clean_host(s: str) -> str:
"""`https://cloud.foo.de/` → `cloud.foo.de`.
Akzeptiert die Eingaben unabhängig davon, ob der User Schema/Slash
mit eingetippt hat. Verhindert Doppel-Schemas wie
`https://https://cloud.foo.de` beim Bauen von URLs.
"""
s = (s or "").strip()
if "://" in s:
s = s.split("://", 1)[1]
return s.rstrip("/")
@dataclass
class Account:
name: str
@@ -16,6 +29,12 @@ class Account:
nextcloudspeicher: Optional[int] = None # GB; None = unlimitiert
nextcloudkennwort: str = ""
def __post_init__(self):
self.pleskhost = clean_host(self.pleskhost)
self.keriohost = clean_host(self.keriohost)
self.nextcloudhost = clean_host(self.nextcloudhost)
self.emailadresse = (self.emailadresse or "").strip()
@property
def vollname(self) -> str:
return f"{self.vorname} {self.name}".strip()