From 7c432e392ba1b921e5bc10e80cd9e9ec90b0f1e6 Mon Sep 17 00:00:00 2001 From: Fathi Ben Nasr Date: Thu, 22 Oct 2026 20:55:38 +0000 Subject: [PATCH] MailSo: a folded plain-text line no longer leaves two spaces Unfolding appended a newline before the continuation line, which kept its own leading whitespace; Header turns the newline into a space, so every fold became two spaces ("et checklist"), carried into reply subjects. The test now compares exactly. --- .../0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php | 8 +++----- test/header-unfold.php | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php index a0b162bfd..2704909c9 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mime/HeaderCollection.php @@ -136,14 +136,12 @@ class HeaderCollection extends \MailSo\Base\Collection $sHeadersValue = \rtrim($sHeadersValue); } - // RFC 2047 6.2: only whitespace between two encoded words is - // dropped; after a plain word the folding space is a real space. + // RFC 5322 unfolding removes the line break and keeps the folding + // whitespace; RFC 2047 6.2 drops it only between two encoded words. if ('=?' === \substr(\ltrim($sHeadersValue), 0, 2) && '?=' === \substr($sValue, -2)) { $sValue .= \ltrim($sHeadersValue); - } else if ('=?' === \substr(\ltrim($sHeadersValue), 0, 2)) { - $sValue .= ' '.\ltrim($sHeadersValue); } else { - $sValue .= "\n".$sHeadersValue; + $sValue .= ' '.\ltrim($sHeadersValue); } } else { if (null !== $sName) { diff --git a/test/header-unfold.php b/test/header-unfold.php index 9152e11a6..4b33c8d2f 100644 --- a/test/header-unfold.php +++ b/test/header-unfold.php @@ -43,7 +43,8 @@ $cases = [ "Hello\r\n world" => 'Hello world', ]; foreach ($cases as $raw => $want) { - $got = preg_replace('/\s+/', ' ', subject($raw)); + // exact: a fold is one space, never two ("et checklist" ended up in replies) + $got = subject($raw); check($got === $want, "got [{$got}], want [{$want}]"); }