Author: Jim Winstead (jimwins)
Date: 2024-09-04T12:41:22-07:00

Commit: 
https://github.com/php/web-news/commit/a6fa6d228b8504cc9ba1c9705a07b33854e0d607
Raw diff: 
https://github.com/php/web-news/commit/a6fa6d228b8504cc9ba1c9705a07b33854e0d607.diff

Replace limited subject rewrite with a more comprehensive regex

Changed paths:
  M  lib/common.php


Diff:

diff --git a/lib/common.php b/lib/common.php
index e7b18c6..c7f10bd 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -181,11 +181,8 @@ function format_subject($s, $charset = 'iso-8859-1')
     global $article;
     $s = recode_header($s, $charset);
 
-    if ((($pos = strpos($s, '[PHP')) !== false || ($pos = strpos($s, '[PEAR')) 
!== false)) {
-        if (($end_pos = strpos($s, ']', $pos)) !== false) {
-            $s = ltrim(substr_replace($s, '', $pos, $end_pos - $pos + 1));
-        }
-    }
+    /* Trim most of the prefixes we add for lists */
+    $s = 
preg_replace('/^(Re:\s*)?(\s*\[(DOC|PEAR|PECL|PHP|ANNOUNCE)(-.+?)?]\s*)+/', 
'\1', $s);
 
     // make this look better on the preview page..
     if (strlen($s) > 150 && !isset($article)) {

Reply via email to