[PHP-WEBMASTER] [web-news] master: Read the RFC wrong, "unfolding" a header should leave the whitespace

Author: Jim Winstead (jimwins)
Date: 2024-08-27T16:20:09-07:00

Commit: Read the RFC wrong, "unfolding" a header should leave the whitespace · php/web-news@64cffef · GitHub
Raw diff: https://github.com/php/web-news/commit/64cffef5d797c26da12b944ec7b68e5b5926faff.diff

Read the RFC wrong, "unfolding" a header should leave the whitespace

Changed paths:
  M lib/fMailbox.php

Diff:

diff --git a/lib/fMailbox.php b/lib/fMailbox.php
index 4ca75d1..60b8afa 100644
--- a/lib/fMailbox.php
+++ b/lib/fMailbox.php
@@ -350,8 +350,8 @@ private static function parseHeaders($headers, $filter = null)

         $parsed_headers = array();
         foreach ($header_lines as $header_line) {
- # remove newlines + leading space or HTAB, per RFC822
- $header_line = preg_replace("#\r\n[ \x09]#", '', $header_line);
+ # "unfolding" headers means just removing \r\n followed by WS per RFC 5322
+ $header_line = preg_replace("#\r\n(\s)#", '\1', $header_line);
             $header_line = trim($header_line);

             list ($header, $value) = preg_split('#:\s*#', $header_line, 2);