Skip to content

fix(mails): use spam-safe characters for email preview padding - #14111

Merged
HarshMN2345 merged 7 commits into
mainfrom
fix/email-preview-padding-hidden-text
Oct 22, 2026
Merged

HarshMN2345 merged 7 commits into
mainfrom
fix/email-preview-padding-hidden-text

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

The Mails and Notifications workers pad the hidden preview with a 7-character group that includes U+200E/U+200F. rspamd ignores whitespace, NBSP and U+200B-U+200D/U+FEFF as preview padding, but counts the direction marks as hidden text. The group was also repeated once per missing character, so a 42-character preview got 756 invisible characters instead of padding to 150. That's over 200 counted characters, so HIDDEN_TEXT (+2.51) and MANY_INVISIBLE_PARTS fire on every auth email.

This changes the padding unit to ‌ , a common preheader pattern, and repeats it only enough to reach 150 characters, counted with mb_strlen so non-ASCII previews are measured correctly. The {{previewWhitespace}} placeholder stays, so custom base templates keep working.

Verification: I rendered the recovery email through the real Mails worker action into a local SMTP sink, then scored it with rspamc (rspamd 4.2.1 image).

  • email-base: 4.32 with HIDDEN_TEXT 2.51 before, 1.48 with no HIDDEN_TEXT after the character change
  • email-base-styled: 3.23 before, 0.29 after
  • Capping the length (second commit, scored in a separate run) removes half the padding and lowers R_PARTS_DIFFER from 0.57 to 0.31 (styled: 0.38 to 0.07).

Fixes #14089

@ghost

ghost commented Oct 5, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The Mails and Notifications workers use zero-width non-joiner and non-breaking-space pairs to pad email previews toward 150 characters, measured with mb_strlen, while retaining the template placeholder. The account recovery e2e test checks for this padding and that direction-mark entities are absent. The latest test update expresses the two direction-mark checks as separate case-insensitive string assertions.

Latest changes: The newest commit replaces the regex-based direction-mark check with separate case-insensitive absence assertions for U+200E and U+200F entities.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 3
File Change
src/Appwrite/Platform/Workers/Mails.php Uses the spam-safe padding pair and a multibyte-aware budget toward 150 preview characters.
src/Appwrite/Platform/Workers/Notifications.php Applies the same spam-safe preview padding and multibyte-aware character budget.
tests/e2e/Services/Account/AccountCustomClientTest.php Checks recovery email preview padding and verifies direction-mark entities are absent using separate case-insensitive assertions.

Reviewed the commits since f918a5d · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

Comment thread src/Appwrite/Platform/Workers/Mails.php Resolved
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/email-preview-padding-hidden-text (after).

Metric Before After Change
🚀 Requests/sec 215.57 217.66 ⚪ +1%
⏱️ Latency P50 79.52 ms 77.93 ms ⚪ -2%
⏱️ Latency P95 184.94 ms 192.73 ms ⚪ +4.2%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 77.93 192.73 13,680 217.66 +7.79
Account 155.25 296.81 720 12.18 +40.13
TablesDB 74.51 139.32 7,440 121.03 -7.27
Storage 72.63 174.65 3,600 60.33 +2.05
Functions 120.79 235.27 1,920 32.96 +21.27

Top API waits (after)

API request Max wait (ms)
account.name.update 474.72
functions.delete 421.25
account.prefs.update 411.82
storage.files.create 373.6
functions.variables.update 349.3

HarshMN2345 and others added 3 commits October 5, 2026 13:41
Each padding unit is two characters, so repeating it once per missing
character doubled the hidden run. Count characters with mb_strlen so
non-ASCII previews are measured correctly.
… marks

The delivered recovery email must pad its preview with zero-width
non-joiner and no-break space pairs, never U+200E/U+200F.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@HarshMN2345
HarshMN2345 merged commit 6093453 into main Oct 22, 2026
33 checks passed
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…ding-hidden-text

fix(mails): use spam-safe characters for email preview padding

(cherry picked from commit 6093453)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug Report: Preview-line whitespace padding in auth emails triggers rspamd HIDDEN_TEXT (+2.5 spam score)

1 participant