Skip to content

fix: unify mail printing#13210

Open
GVodyanov wants to merge 1 commit into
mainfrom
fix/unify-mail-print-pipeline
Open

fix: unify mail printing#13210
GVodyanov wants to merge 1 commit into
mainfrom
fix/unify-mail-print-pipeline

Conversation

@GVodyanov

Copy link
Copy Markdown
Contributor

Fix mail printing... again

This makes emails with multiple images not be all forced into one page

2026-07-03-181738_2560x1440_scrot

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Grigory Vodyanov <scratchx@gmx.com>
@ChristophWurst

Copy link
Copy Markdown
Member

Do you have before/after examples and can tell us what we should test?

Code looks … complicated

@ChristophWurst

Copy link
Copy Markdown
Member

/backport to stable5.10

@GVodyanov

Copy link
Copy Markdown
Contributor Author

Do you have before/after examples and can tell us what we should test?

Code looks … complicated

Yeah fair enough

Here's a file which the old version for me had trouble printing, it had an extra page and lots of white space:

Grazie da Italo!.eml

Here is a full changelog:

  • Unifies the two separate print code paths (Ctrl/Cmd+P for a whole thread, and the "⋯ → Print" action for a single message) into one shared pipeline in src/util/printMessage.ts.
  • Fixes: wrong message body could be printed for the "⋯ → Print" action in threads mixing plain-text and HTML messages, because the old code picked the DOM node via querySelectorAll(...)[threadIndex * 2], an index that only holds if every prior message is HTML.
  • Fixes: printed header could be enlarged/misstyled by the email's own CSS (the old code inserted it into the same iframe as the email).
  • Fixes: brief visible flash in the open message when printing a single message (old code inserted/removed content in the live, on-screen iframe).
  • Fixes: Ctrl+P could throw/fail on a message with no "To" recipient (e.g. Bcc-only).
  • Adds: Cc/Bcc are now shown in the printed header (previously omitted, or folded anonymously into a thread-wide participant list).
  • Hardens security: printed content now renders in a sandboxed iframe (allow-same-origin allow-modals, no scripts) instead of an unsandboxed one; <script> tags and iframe-resizer markers are stripped as defense in depth.
  • Cleanup now waits on the afterprint event (with a 60s fallback) instead of guessing with fixed setTimeouts.
  • Native browser print (outside the app's own Ctrl+P handler) now hides app chrome (nav, message list, composer, attachments) via CSS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants