Author: Jim Winstead (jimwins) Date: 2024-08-27T15:09:20-07:00 Commit: https://github.com/php/web-news/commit/053363cbf0451a26c37c2cf81d6f2d7bac19fc73 Raw diff: https://github.com/php/web-news/commit/053363cbf0451a26c37c2cf81d6f2d7bac19fc73.diff
Fix minor header formatting issues Changed paths: M lib/common.php M lib/fMailbox.php Diff: diff --git a/lib/common.php b/lib/common.php index 1832175..e7b18c6 100644 --- a/lib/common.php +++ b/lib/common.php @@ -119,7 +119,7 @@ function decode_header($charset, $encoding, $text) if (strtolower($encoding) == "b") { $text = base64_decode($text); } else { - $text = quoted_printable_decode($text); + $text = str_replace('_', ' ', quoted_printable_decode($text)); } return to_utf8($text, $charset); } @@ -201,7 +201,7 @@ function format_title($s, $charset = 'iso-8859-1') { global $article; $s = recode_header($s, $charset); - $s = preg_replace("/^(Re: *)?\[(PHP|PEAR)(-.*)?\] /i", "\\1", $s); + $s = preg_replace("/^(Re: *)?\[(PHP|PEAR)(-.*?)?\] /i", "\\1", $s); // make this look better on the preview page.. if (strlen($s) > 150 && !isset($article)) { $s = substr($s, 0, 150) . "..."; diff --git a/lib/fMailbox.php b/lib/fMailbox.php index 78a5169..4ca75d1 100644 --- a/lib/fMailbox.php +++ b/lib/fMailbox.php @@ -350,7 +350,8 @@ private static function parseHeaders($headers, $filter = null) $parsed_headers = array(); foreach ($header_lines as $header_line) { - $header_line = preg_replace("#\r\n\s+#", ' ', $header_line); + # remove newlines + leading space or HTAB, per RFC822 + $header_line = preg_replace("#\r\n[ \x09]#", '', $header_line); $header_line = trim($header_line); list ($header, $value) = preg_split('#:\s*#', $header_line, 2);