mail-to-ntfy

Check-in [12256d74f8]
Login

Check-in [12256d74f8]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Headers sanitizen om foutmeldingen te voorkomen.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 12256d74f848305a74f04e3e70247f6a5cc62bd8d51e1e6cb8621a4b30a29755
User & Date: tinus 2025-04-12 09:38:57.497
Context
2025-04-12
09:39
Ook shell expansion toepassen op cache file. check-in: 0ecc9d21f6 user: tinus tags: trunk
09:38
Headers sanitizen om foutmeldingen te voorkomen. check-in: 12256d74f8 user: tinus tags: trunk
09:32
Debugcode: stack trace van exception ook afdrukken. check-in: 234050ceea user: tinus tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to mail-to-ntfy.py.
133
134
135
136
137
138
139




140
141
142
143
144
145
146
147
148
149
150
    return {"processed_emails": []}

def save_cache(cache):
    """Save processed email IDs to cache file"""
    with open(CACHE_FILE, 'w') as f:
        json.dump(cache, f)





def send_notification(subject, body):
    """Send notification to ntfy.sh"""
    headers = {
        "Title": subject,
        "Priority": "high",
        "Tags": "email,house"
    }
    
    # Beperkt berichtlengte om efficiƫnt te blijven
    if len(body) > 2500:
        body = body[:2497] + "..."







>
>
>
>



|







133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
    return {"processed_emails": []}

def save_cache(cache):
    """Save processed email IDs to cache file"""
    with open(CACHE_FILE, 'w') as f:
        json.dump(cache, f)

def sanitize_header(value):
    """Sanitize header value to remove invalid characters."""
    return re.sub(r'[\r\n]+', ' ', value).strip()

def send_notification(subject, body):
    """Send notification to ntfy.sh"""
    headers = {
        "Title": sanitize_header(subject),  # Sanitize the subject
        "Priority": "high",
        "Tags": "email,house"
    }
    
    # Beperkt berichtlengte om efficiƫnt te blijven
    if len(body) > 2500:
        body = body[:2497] + "..."