summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Uckelman <uckelman@nomic.net>2012-02-27 02:23:18 +0100
committerJoel Uckelman <uckelman@nomic.net>2012-02-27 02:23:18 +0100
commit9ed92aaa0cf387bd70072b34c788d15a63f0b39d (patch)
tree4c8e4e397c1ed91d186597dbfd832f891625b12f
parent04e2364afed194dbb7b4fbd8b597000c04dc63ed (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.
-rw-r--r--src/build_post.php17
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;
}
?>