diff options
author | Gunnar Wrobel <wrobel@pardus.de> | 2008-02-27 07:09:56 (GMT) |
---|---|---|
committer | Gunnar Wrobel <wrobel@pardus.de> | 2008-02-27 07:09:56 (GMT) |
commit | 0e3e323566cd5716569644d5e0dbedd22fb4efbb (patch) | |
tree | 1c981915e943d7beaa533d09b9c22689e7a8bef2 /php-kolab/Kolab_Filter | |
parent | a597cf4d29e37b0a695a876d6ef63e466945e611 (diff) | |
download | server-0e3e323566cd5716569644d5e0dbedd22fb4efbb.tar.gz |
Add a test fo rkolab/issue1272 and fix a notice when the sender does only use a mail address (no plain text name.
Diffstat (limited to 'php-kolab/Kolab_Filter')
-rw-r--r-- | php-kolab/Kolab_Filter/ChangeLog | 7 | ||||
-rw-r--r-- | php-kolab/Kolab_Filter/Filter/Content.php | 9 | ||||
-rw-r--r-- | php-kolab/Kolab_Filter/tests/_data/forged.eml | 2 | ||||
-rw-r--r-- | php-kolab/Kolab_Filter/tests/_data/vacation.eml | 14 | ||||
-rw-r--r-- | php-kolab/Kolab_Filter/tests/forged_sender.phpt | 2 | ||||
-rw-r--r-- | php-kolab/Kolab_Filter/tests/forged_vacation_msg.phpt | 58 | ||||
-rw-r--r-- | php-kolab/Kolab_Filter/tests/privileged_network.phpt | 2 |
7 files changed, 90 insertions, 4 deletions
diff --git a/php-kolab/Kolab_Filter/ChangeLog b/php-kolab/Kolab_Filter/ChangeLog index f3a1572..9fef999 100644 --- a/php-kolab/Kolab_Filter/ChangeLog +++ b/php-kolab/Kolab_Filter/ChangeLog @@ -1,3 +1,10 @@ +2008-02-27 Gunnar Wrobel <p@rdus.de> + + * tests/forged_vacation_msg.phpt: Add a test for kolab/issue1272 + + * Filter/Content.php: Fix a notice when the sender does not use a + name but only a mail address. + 2008-02-26 Gunnar Wrobel <p@rdus.de> * Filter/Resource.php: Fix undefined variables. diff --git a/php-kolab/Kolab_Filter/Filter/Content.php b/php-kolab/Kolab_Filter/Filter/Content.php index fe2b75c..4b1913e 100644 --- a/php-kolab/Kolab_Filter/Filter/Content.php +++ b/php-kolab/Kolab_Filter/Filter/Content.php @@ -522,7 +522,14 @@ function verify_sender($sasluser, $sender, $fromhdr, $client_addr) { Horde::logMessage(sprintf(_("%s is not an allowed From address for unauthenticated users, rewriting."), $from), __FILE__, __LINE__, PEAR_LOG_DEBUG); if (strpos( $fromhdr, $untrusted )===false) { - return '"'.str_replace(array("\\",'"'),array("\\\\",'\"'),$adr->personal).' '.$untrusted.'" '.'<'.$from.'>'; + if (property_exists($adr, 'personal')) { + $name = str_replace(array("\\", '"'), + array("\\\\",'\"'), + $adr->personal); + } else { + $name = ''; + } + return '"' . $name . ' ' . $untrusted . '" <' . $from . '>'; } else { return true; } diff --git a/php-kolab/Kolab_Filter/tests/_data/forged.eml b/php-kolab/Kolab_Filter/tests/_data/forged.eml index a0745e2..420eea4 100644 --- a/php-kolab/Kolab_Filter/tests/_data/forged.eml +++ b/php-kolab/Kolab_Filter/tests/_data/forged.eml @@ -3,7 +3,7 @@ Received: from localhost (fqdn.example.com [127.0.0.1]) by demo.example.com (Cyrus v2.3.9-openpkg) with LMTPA; Sat, 10 Nov 2007 20:44:52 +0100 Message-ID: <1d2101c823d2$3555aa10$ac112c15@Meredith> -From: "Me" <me@example.com> +From: me@example.com To: "You" <you@example.com> Subject: Me to You Date: Sat, 10 Nov 2007 22:45:12 +0300 diff --git a/php-kolab/Kolab_Filter/tests/_data/vacation.eml b/php-kolab/Kolab_Filter/tests/_data/vacation.eml new file mode 100644 index 0000000..6dba0ef --- /dev/null +++ b/php-kolab/Kolab_Filter/tests/_data/vacation.eml @@ -0,0 +1,14 @@ +Return-Path: <me@example.com> +Received: from localhost (fqdn.example.com [127.0.0.1]) + by demo.example.com (Cyrus v2.3.9-openpkg) with LMTPA; + Sat, 10 Nov 2007 20:44:52 +0100 +Message-ID: <1d2101c823d2$3555aa10$ac112c15@Meredith> +From: me@example.com +To: you@example.net +Subject: Me to You +Date: Sat, 10 Nov 2007 22:45:12 +0300 +User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1.50 (x86_64-pc-linux-gnu) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii + +I'm on vacation diff --git a/php-kolab/Kolab_Filter/tests/forged_sender.phpt b/php-kolab/Kolab_Filter/tests/forged_sender.phpt index 51edd15..4eb7fae 100644 --- a/php-kolab/Kolab_Filter/tests/forged_sender.phpt +++ b/php-kolab/Kolab_Filter/tests/forged_sender.phpt @@ -44,7 +44,7 @@ Received: from localhost (fqdn.example.com [127.0.0.1]) by demo.example.com (Cyrus v2.3.9-openpkg) with LMTPA; Sat, 10 Nov 2007 20:44:52 +0100 Message-ID: <1d2101c823d2$3555aa10$ac112c15@Meredith> -From: "Me (UNTRUSTED, sender <me@example.com> is not authenticated)" <me@example.com> +From: " (UNTRUSTED, sender <me@example.com> is not authenticated)" <me@example.com> To: "You" <you@example.com> Subject: Me to You Date: Sat, 10 Nov 2007 22:45:12 +0300 diff --git a/php-kolab/Kolab_Filter/tests/forged_vacation_msg.phpt b/php-kolab/Kolab_Filter/tests/forged_vacation_msg.phpt new file mode 100644 index 0000000..992b4ea --- /dev/null +++ b/php-kolab/Kolab_Filter/tests/forged_vacation_msg.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test sending a mail as an untrusted sender. +--SKIPIF-- +--FILE-- +<?php +require_once 'Kolab/Filter/Content.php'; + +/* Our test configuration */ +$conf = array(); +$conf['log']['enabled'] = true; +$conf['log']['priority'] = PEAR_LOG_DEBUG; // Leave this on DEBUG for now. We just restructured the package... +$conf['log']['type'] = 'console'; +$conf['log']['name'] = 'ignored'; +$conf['log']['ident'] = 'Kolab Filter'; +$conf['log']['params']['append'] = true; +$conf['filter']['tempdir'] = './tmp'; +$conf['filter']['reject_forged_from_header'] = false; +$conf['filter']['email_domain'] = 'example.com'; + +/* Use an empty client address here, indicating that the mail is sent + * via local sendmail -> We want to trust local sendmail */ +$_SERVER['argv'] = array('test', '-s', 'me@example.com', '-u', '', '-r', 'you@example.net', '-c', ''); +$logger = Horde::getLogger(); + +$logger->_lineFormat = '%2$s [%3$s] %7$s'; +// Activate this if you need the log information. This will +// make the test fail though +//$logger->_lineFormat = '%2$s [%3$s] %4$s %7$s'; + +$inh = fopen('_data/vacation.eml', 'r'); + +/* Setup the class */ +$parser = &new Filter_Content('StdOut', true); + +/* Parse the mail */ +$parser->parse($inh); +?> +--EXPECT-- +Kolab Filter [debug] logMessage +Kolab Filter [debug] logMessage +Mail from sender: me@example.com +Mail to recipient: you@example.net +Return-Path: <me@example.com> +Received: from localhost (fqdn.example.com [127.0.0.1]) + by demo.example.com (Cyrus v2.3.9-openpkg) with LMTPA; + Sat, 10 Nov 2007 20:44:52 +0100 +Message-ID: <1d2101c823d2$3555aa10$ac112c15@Meredith> +From: me@example.com +To: you@example.net +Subject: Me to You +Date: Sat, 10 Nov 2007 22:45:12 +0300 +User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1.50 (x86_64-pc-linux-gnu) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii + +I'm on vacation +. +Kolab Filter [info] logMessage diff --git a/php-kolab/Kolab_Filter/tests/privileged_network.phpt b/php-kolab/Kolab_Filter/tests/privileged_network.phpt index a4de8e3..8158e2f 100644 --- a/php-kolab/Kolab_Filter/tests/privileged_network.phpt +++ b/php-kolab/Kolab_Filter/tests/privileged_network.phpt @@ -43,7 +43,7 @@ Received: from localhost (fqdn.example.com [127.0.0.1]) by demo.example.com (Cyrus v2.3.9-openpkg) with LMTPA; Sat, 10 Nov 2007 20:44:52 +0100 Message-ID: <1d2101c823d2$3555aa10$ac112c15@Meredith> -From: "Me" <me@example.com> +From: me@example.com To: "You" <you@example.com> Subject: Me to You Date: Sat, 10 Nov 2007 22:45:12 +0300 |