This commit is contained in:
Andreas Knuth 2026-01-24 16:56:37 -06:00
parent f9e866d948
commit 3884abc695
1 changed files with 3 additions and 11 deletions

View File

@ -15,8 +15,6 @@ VMAIL_BASE = '/var/mail'
dynamodb = boto3.resource('dynamodb', region_name=REGION) dynamodb = boto3.resource('dynamodb', region_name=REGION)
table = dynamodb.Table(TABLE) table = dynamodb.Table(TABLE)
import json
def generate_sieve(email, rules): def generate_sieve(email, rules):
"""Generate Sieve script from DynamoDB rules""" """Generate Sieve script from DynamoDB rules"""
lines = ['require ["copy","vacation","variables"];', ''] lines = ['require ["copy","vacation","variables"];', '']
@ -49,23 +47,17 @@ def generate_sieve(email, rules):
if content_type == 'html': if content_type == 'html':
lines.extend([ lines.extend([
f'vacation :days 1 :from "{email}" :mime text:', f'vacation :days 1 :from "{email}" :mime text:',
# HIER ENTFERNT: Die extra Leerzeile war falsch.
# .join() macht bereits den nötigen Umbruch nach 'text:'
'Content-Type: text/html; charset=utf-8', 'Content-Type: text/html; charset=utf-8',
'', '',
msg, msg,
'.' '.',
';' # <--- HIER WAR DER FEHLER
]) ])
else: else:
# WICHTIG: Escape double quotes in msg, sonst Syntax-Fehler bei "I'm here" # Sicherheitshalber JSON dump für escaping von Anführungszeichen nutzen
# json.dumps erstellt einen String mit Anführungszeichen (z.B. "Text"),
# wir brauchen aber nur den escaped Inhalt.
safe_msg = json.dumps(msg, ensure_ascii=False) safe_msg = json.dumps(msg, ensure_ascii=False)
# json.dumps gibt '"msg"' zurück, wir nutzen das direkt
lines.append(f'vacation :days 1 :from "{email}" {safe_msg};') lines.append(f'vacation :days 1 :from "{email}" {safe_msg};')
# WICHTIG: Ein Sieve-Script (und speziell der Multi-Line Block)
# muss zwingend mit einem Zeilenumbruch enden.
return '\n'.join(lines) + '\n' return '\n'.join(lines) + '\n'
def sync(): def sync():