Skip to content

Commit

Permalink
[mms] Fix escaping periods that begin a line of DATA input.
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 19, 2013
1 parent 68fa7ed commit 72de48b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion framework/Smtp/lib/Horde/Smtp/Filter/Data.php
Expand Up @@ -48,7 +48,7 @@ public function filter($in, $out, &$consumed, $closing)
// EOLs need to be CRLF; double leading periods.
$bucket->data = preg_replace(
array("/(?:\r\n|\n|\r(?!\n))/", "/\n\./"),
array("\r\n", '..'),
array("\r\n", "\n.."),
$bucket->data
);

Expand Down
10 changes: 6 additions & 4 deletions framework/Smtp/package.xml
Expand Up @@ -10,7 +10,7 @@
<email>slusarz@horde.org</email>
<active>yes</active>
</lead>
<date>2013-10-15</date>
<date>2013-10-19</date>
<version>
<release>1.2.5</release>
<api>1.2.0</api>
Expand All @@ -21,7 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix escaping periods that begin a line of DATA input.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -59,6 +59,7 @@
<file name="AllTests.php" role="test" />
<file name="bootstrap.php" role="test" />
<file name="conf.php.dist" role="test" />
<file name="FilterDataTest.php" role="test" />
<file name="phpunit.xml" role="test" />
<file name="RemoteServerTest.php" role="test" />
</dir> <!-- /test/Horde/Smtp -->
Expand Down Expand Up @@ -142,6 +143,7 @@
<install as="Horde/Smtp/AllTests.php" name="test/Horde/Smtp/AllTests.php" />
<install as="Horde/Smtp/bootstrap.php" name="test/Horde/Smtp/bootstrap.php" />
<install as="Horde/Smtp/conf.php.dist" name="test/Horde/Smtp/conf.php.dist" />
<install as="Horde/Smtp/FilterDataTest.php" name="test/Horde/Smtp/FilterDataTest.php" />
<install as="Horde/Smtp/phpunit.xml" name="test/Horde/Smtp/phpunit.xml" />
<install as="Horde/Smtp/RemoteServerTest.php" name="test/Horde/Smtp/RemoteServerTest.php" />
</filelist>
Expand Down Expand Up @@ -253,10 +255,10 @@
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2013-10-15</date>
<date>2013-10-19</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix escaping periods that begin a line of DATA input.
</notes>
</release>
</changelog>
Expand Down
53 changes: 53 additions & 0 deletions framework/Smtp/test/Horde/Smtp/FilterDataTest.php
@@ -0,0 +1,53 @@
<?php
/**
* Copyright 2013 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @copyright 2013 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Smtp
* @subpackage UnitTests
*/

/**
* Test for the SMTP DATA filter.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2013 Horde LLC
* @ignore
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Smtp
* @subpackage UnitTests
*/
class Horde_Smtp_FilterDataTest extends Horde_Test_Case
{
private $stream;

public function setUp()
{
$this->stream = fopen('php://temp', 'r+');
stream_filter_register('horde_smtp_data', 'Horde_Smtp_Filter_Data');
stream_filter_append($this->stream, 'horde_smtp_data', STREAM_FILTER_READ);
}

public function tearDown()
{
fclose($this->stream);
}

public function testLeadingPeriodsEscape()
{
fwrite($this->stream, "Foo\r\n.\r\nFoo\r\n");
rewind($this->stream);

$this->assertEquals(
"Foo\r\n..\r\nFoo\r\n",
stream_get_contents($this->stream)
);
}

}

0 comments on commit 72de48b

Please sign in to comment.