fix(react-email): leave direction marks out of the preview padding

Merged
HA
3d ago
+22-6

Bug fix for #3771.

<Preview> pads the preview with \xa0‌​‍‎‏. rspamd's HIDDEN_TEXT rule ignores all of these as preview padding except the direction marks U+200E and U+200F. A typical 40-character preview gets 320 of them, which is above the rule's 200-character threshold.

This drops the two direction marks from the padding and keeps the other five characters and the length logic as they are. It also updates the renderWhiteSpace test and the two inline snapshots that contain the padding, and adds a patch changeset for react-email.

Verification: I rendered an email with <Preview>Reset your Acme password using the link.</Preview> and scored it with rspamc (rspamd/rspamd:latest, 4.2.1):

  • Before: 9.19, with HIDDEN_TEXT (3.54) and MANY_INVISIBLE_PARTS
  • After: 5.60, with neither rule

The preview and get-email-component tests pass. The pretty test still passes; it uses the old padding as static input.


Summary by cubic

Fixes <Preview> padding in react-email so spam filters such as rspamd no longer flag emails as hidden text. The hidden padding previously included the direction marks U+200E and U+200F, which rspamd's HIDDEN_TEXT rule counts, pushing a 40-character preview past its 200-character threshold.

  • Drops the two direction marks from the padding and keeps the other five characters and the length logic unchanged.
  • Updates the renderWhiteSpace test, the inline snapshots, and the export and get-email-component snapshots, and adds a regression test asserting padding uses only characters spam filters ignore.
  • Adds a patch changeset for react-email; the padding sequence is now \xa0‌​‍, so update any code that matches the old sequence.
  • Verified with rspamc: the sample preview's score dropped from 9.19 to 5.60, with HIDDEN_TEXT and MANY_INVISIBLE_PARTS no longer triggering.