summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Uckelman <uckelman@nomic.net>2012-03-18 01:59:16 +0100
committerJoel Uckelman <uckelman@nomic.net>2012-03-18 01:59:16 +0100
commitd365166dc05f1562503eb68900c227e6a64c964f (patch)
tree290c08987ce3d246792aa18ff0a52f26737b4a11
parent1aaeb20c92cc3650b891ee4bf674eccf402fcd3b (diff)
Moved list footer stripping to strip_list_footer().
-rw-r--r--src/PhpBB3Impl.php2
-rw-r--r--src/build_post.php4
-rw-r--r--test/32659
-rw-r--r--test/build_postTest.php35
4 files changed, 99 insertions, 1 deletions
diff --git a/src/PhpBB3Impl.php b/src/PhpBB3Impl.php
index af1d977..06b0427 100644
--- a/src/PhpBB3Impl.php
+++ b/src/PhpBB3Impl.php
@@ -212,7 +212,7 @@ class PhpBB3Impl implements PhpBB3 {
# FIXME: extract the footer pattern into a config file?
# strip the list footer
- $message = preg_replace("/^_______________________________________________\\r\\nmessages mailing list\\r\\nmessages@vassalengine.org\\r\\nhttp:\/\/www.vassalengine.org\/mailman\/listinfo\/messages.*/ms", '', $message);
+ $message = strip_list_footer($message, "/^_______________________________________________\\r\\nmessages mailing list\\r\\nmessages@vassalengine.org\\r\\nhttp:\/\/www.vassalengine.org\/mailman\/listinfo\/messages.*/ms");
# TODO: convert > quoting into BBCode
diff --git a/src/build_post.php b/src/build_post.php
index d889b92..d6d23a7 100644
--- a/src/build_post.php
+++ b/src/build_post.php
@@ -25,4 +25,8 @@ function build_post_subject($listtag, $forumtag, $subject, $reply) {
return $subject;
}
+function strip_list_footer($message, $fpattern) {
+ return preg_replace($fpattern, '', $message);
+}
+
?>
diff --git a/test/326 b/test/326
new file mode 100644
index 0000000..2a763ae
--- /dev/null
+++ b/test/326
@@ -0,0 +1,59 @@
+Return-Path: <messages-bounces@vassalengine.org>
+X-Original-To: uckelman@nomic.net
+Delivered-To: uckelman@nomic.net
+Received: from one.vassalengine.org (one.vassalengine.org [68.14.242.202])
+ by charybdis.ellipsis.cx (Postfix) with ESMTP id 7537B360D13
+ for <uckelman@nomic.net>; Mon, 12 Mar 2012 22:39:31 -0700 (MST)
+Received: from one.vassalengine.org (localhost [IPv6:::1])
+ by one.vassalengine.org (Postfix) with ESMTP id 062DA5D;
+ Mon, 12 Mar 2012 22:39:30 -0700 (MST)
+X-Original-To: messages@vassalengine.org
+Delivered-To: messages@vassalengine.org
+Received: from charybdis.ellipsis.cx (charybdis.ellipsis.cx [68.14.242.200])
+ by one.vassalengine.org (Postfix) with ESMTP id 935325B
+ for <messages@vassalengine.org>; Mon, 12 Mar 2012 22:39:28 -0700 (MST)
+Received: by charybdis.ellipsis.cx (Postfix, from userid 1000)
+ id A581E360D1E; Mon, 12 Mar 2012 22:39:27 -0700 (MST)
+To: The mailing list for VASSAL <messages@vassalengine.org>
+In-reply-to: <1331617112.31989.9776.bridge@www.vassalengine.org>
+References: <1331616274.31988.9775.bridge@www.vassalengine.org>
+ <1331617112.31989.9776.bridge@www.vassalengine.org>
+Comments: In-reply-to uckelman <uckelman@nomic.net>
+ message dated "Mon, 12 Mar 2012 22:38:32 -0700."
+Date: Mon, 12 Mar 2012 22:39:27 -0700
+From: Joel Uckelman <uckelman@nomic.net>
+Message-Id: <20120313053927.A581E360D1E@charybdis.ellipsis.cx>
+Subject: Re: [messages] [General Discussion] Upgraded web server
+X-BeenThere: messages@vassalengine.org
+X-Mailman-Version: 2.1.14
+Precedence: list
+Reply-To: The mailing list for VASSAL <messages@vassalengine.org>
+List-Id: The mailing list for VASSAL <messages.vassalengine.org>
+List-Unsubscribe: <http://www.vassalengine.org/mailman/options/messages>,
+ <mailto:messages-request@vassalengine.org?subject=unsubscribe>
+List-Archive: <http://www.vassalengine.org/pipermail/messages/>
+List-Post: <mailto:messages@vassalengine.org>
+List-Help: <mailto:messages-request@vassalengine.org?subject=help>
+List-Subscribe: <http://www.vassalengine.org/mailman/listinfo/messages>,
+ <mailto:messages-request@vassalengine.org?subject=subscribe>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+Errors-To: messages-bounces@vassalengine.org
+Sender: messages-bounces@vassalengine.org
+X-Bogosity: Unsure, tests=bogofilter, spamicity=0.500000, version=1.2.2
+
+Thus spake uckelman:
+> The changes appear to have munged SELinux permissions for the list
+> bridge. Trying again...
+>
+
+And checking that the bridge works in the other direction...
+
+--
+J.
+_______________________________________________
+messages mailing list
+messages@vassalengine.org
+http://www.vassalengine.org/mailman/listinfo/messages
+
diff --git a/test/build_postTest.php b/test/build_postTest.php
index 5e8017e..3dc2cb5 100644
--- a/test/build_postTest.php
+++ b/test/build_postTest.php
@@ -60,6 +60,41 @@ class build_post_test extends PHPUnit_Framework_TestCase {
array('[l]', '[f]', 'Edit: Re: Subject [l][f] Subject', true, 'Re: Subject Subject')
);
}
+
+ function test_strip_list_footer() {
+ $exp = "Thus spake uckelman:
+> The changes appear to have munged SELinux permissions for the list
+> bridge. Trying again...
+>
+
+And checking that the bridge works in the other direction...
+
+--
+J.
+";
+
+ $fpat = "/^_______________________________________________\nmessages mailing list\nmessages@vassalengine.org\nhttp:\/\/www.vassalengine.org\/mailman\/listinfo\/messages.*/ms";
+
+ $this->assertEquals($exp, strip_list_footer("Thus spake uckelman:
+> The changes appear to have munged SELinux permissions for the list
+> bridge. Trying again...
+>
+
+And checking that the bridge works in the other direction...
+
+--
+J.
+_______________________________________________
+messages mailing list
+messages@vassalengine.org
+http://www.vassalengine.org/mailman/listinfo/messages
+", $fpat));
+
+ $msg = new MailmanMessage(file_get_contents(__DIR__ . '/326'));
+ list($text, ) = $msg->getFlattenedParts();
+
+ $this->assertEquals($exp, strip_list_footer($text, $fpat));
+ }
}
?>