Zeige PDF-Anlagen in der Mail-Ansicht, damit der Browser sie nicht unter einem zufälligen Namen speichert.
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Successful in 6m16s
Test Suite / smoke-dev (push) Successful in 1s
Test Suite / frontend-build (push) Successful in 22s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-23 12:59:07 +02:00
1 parent d0f09830bb
commit cd239a3ab8
5 files changed
+164 -26

No files matched your search

+34
View File
@@ -104,6 +104,40 @@ def test_parse_mail_keeps_names_html_and_attached_messages():
assert named.attachments[0].data == b"pdf"
def test_an_undecoded_pdf_stays_a_named_pdf():
import base64
from app.media.storage import content_disposition
pdf = b"%PDF-1.4\n1 0 obj\n<<>>\nendobj\ntrailer\n<<>>\n%%EOF\n"
raw = (
b"Subject: Scan\r\n"
b"MIME-Version: 1.0\r\n"
b"Content-Type: multipart/mixed; boundary=bound\r\n"
b"\r\n"
b"--bound\r\n"
b"Content-Type: text/plain; charset=utf-8\r\n"
b"\r\n"
b"text\r\n"
b"--bound\r\n"
b"Content-Type: application/octet-stream\r\n"
b"Content-Transfer-Encoding: 8bit\r\n"
b"Content-Disposition: attachment; filename=\"scan-7f3a9c\"\r\n"
b"\r\n"
+ base64.b64encode(pdf) + b"\r\n"
b"--bound--\r\n"
)
item = parse_mail(raw).attachments[0]
assert item.data.startswith(b"%PDF")
assert item.media_type == "application/pdf"
assert item.display_name == "scan-7f3a9c.pdf"
header = content_disposition("\u00dcbergabe.pdf", inline=True)
assert header.startswith("inline;")
header.encode("ascii")
assert ".pdf" in header
assert "filename*=UTF-8''" in header
assert "%C3%9Cbergabe.pdf" in header
class QuotedIMAP:
def __init__(self, *args, **kwargs):
self.untagged_responses = {}