From 9ed92aaa0cf387bd70072b34c788d15a63f0b39d Mon Sep 17 00:00:00 2001 From: Joel Uckelman Date: Mon, 27 Feb 2012 02:23:18 +0100 Subject: PREG_OFFSET_CAPTURE is useless, as it gives start offsets, not end offsets, and our pattern is anchored at the start. Use match length instead. --- src/build_post.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/build_post.php b/src/build_post.php index 2685d69..832fa7a 100644 --- a/src/build_post.php +++ b/src/build_post.php @@ -8,23 +8,20 @@ function build_post_subject($listtag, $forumtag, $subject) { // strip the '[list]' and '[forum]' tags $tagpat = '/(' . preg_quote($listtag, '/') . '|' . preg_quote($forumtag, '/') . ')\\s*/'; - $subject = preg_replace($tagpat, '', $subject); + $subj = preg_replace($tagpat, '', $subject); // strip leading sequences of Re-equivalents - if (preg_match( - '/^((RE|AW|SV|VS)(\\[\\d+\\])?:\\s*)+/i', - $subject, $m, PREG_OFFSET_CAPTURE - )) { - $subject = substr($subject, $m[0][1]); + if (preg_match('/^(?:(?:RE|AW|SV|VS)(?:\\[\\d+\\])?:\\s*)+/i', $subj, $m)) { + $subj = substr($subj, strlen($m[0])); } // ensure nonempty subject - $subject = trim($subject); - if ($subject == '') { - $subject = '(no subject)'; + $subj = trim($subj); + if ($subj == '') { + $subj = '(no subject)'; } - return $subject; + return $subj; } ?> -- cgit v1.2.3