KI-AGENT: Gmail-Postfachnamen korrekt quotieren
This commit is contained in:
@@ -62,6 +62,12 @@ def unique_path(path: Path, overwrite: bool) -> Path:
|
||||
counter += 1
|
||||
|
||||
|
||||
def quote_imap_string(value: str) -> str:
|
||||
"""Maskiert einen Text als quotierten IMAP-String."""
|
||||
escaped = value.replace("\\", "\\\\").replace('"', '\\"')
|
||||
return f'"{escaped}"'
|
||||
|
||||
|
||||
def message_folder(message: Message, message_id: bytes) -> str:
|
||||
date_header = decode_mime_header(message.get("Date"))
|
||||
subject = safe_filename(decode_mime_header(message.get("Subject"), "ohne-betreff"), "ohne-betreff")
|
||||
@@ -132,7 +138,9 @@ def download_attachments(args: argparse.Namespace) -> DownloadStats:
|
||||
output_dir = args.output.expanduser().resolve()
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
status, select_data = client.select(args.mailbox, readonly=True)
|
||||
# imaplib quotiert Argumente nicht automatisch. Gmail-Postfächer wie
|
||||
# "[Gmail]/All Mail" würden deshalb wegen des Leerzeichens fehlschlagen.
|
||||
status, select_data = client.select(quote_imap_string(args.mailbox), readonly=True)
|
||||
if status != "OK":
|
||||
details = b" ".join(select_data or []).decode("utf-8", errors="replace")
|
||||
raise RuntimeError(
|
||||
|
||||
Reference in New Issue
Block a user