diff options
author | Joel Uckelman <uckelman@nomic.net> | 2012-02-27 02:23:18 +0100 |
---|---|---|
committer | Joel Uckelman <uckelman@nomic.net> | 2012-02-27 02:23:18 +0100 |
commit | 9ed92aaa0cf387bd70072b34c788d15a63f0b39d (patch) | |
tree | 4c8e4e397c1ed91d186597dbfd832f891625b12f /src/build_post.php | |
parent | 04e2364afed194dbb7b4fbd8b597000c04dc63ed (diff) |
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.
Diffstat (limited to 'src/build_post.php')
-rw-r--r-- | src/build_post.php | 17 |
1 files 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; } ?> |