From d365166dc05f1562503eb68900c227e6a64c964f Mon Sep 17 00:00:00 2001 From: Joel Uckelman Date: Sun, 18 Mar 2012 01:59:16 +0100 Subject: Moved list footer stripping to strip_list_footer(). --- src/PhpBB3Impl.php | 2 +- src/build_post.php | 4 ++++ test/326 | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ test/build_postTest.php | 35 +++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 test/326 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: +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 ; 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 ; 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 +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 + message dated "Mon, 12 Mar 2012 22:38:32 -0700." +Date: Mon, 12 Mar 2012 22:39:27 -0700 +From: Joel Uckelman +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 +List-Id: The mailing list for VASSAL +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-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)); + } } ?> -- cgit v1.2.3