Skip to content

Commit

Permalink
[mms] Fix Horde_Mime_Part#buildMimeIds() when called on the base embe…
Browse files Browse the repository at this point in the history
…dded object of a parent part (Bug #13117).
  • Loading branch information
slusarz committed Apr 22, 2014
1 parent 46cc7d0 commit e2e1e3c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion framework/Mime/lib/Horde/Mime/Part.php
Expand Up @@ -1584,7 +1584,7 @@ public function buildMimeIds($id = null, $rfc822 = false)
} else {
$this->setMimeId($id);
$id = $id
? $id . '.'
? ((substr($id, -2) === '.0') ? substr($id, 0, -1) : ($id . '.'))
: '';

if ($this->getType() == 'message/rfc822') {
Expand Down
10 changes: 6 additions & 4 deletions framework/Mime/package.xml
Expand Up @@ -17,7 +17,7 @@
<email>slusarz@horde.org</email>
<active>yes</active>
</lead>
<date>2014-03-16</date>
<date>2014-04-22</date>
<version>
<release>2.3.1</release>
<api>2.3.0</api>
Expand All @@ -28,7 +28,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix Horde_Mime_Part#buildMimeIds() when called on the base embedded object of a parent part (Bug #13117).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -328,6 +328,7 @@
<file name="bug12536.txt" role="test" />
<file name="bug12842_a.txt" role="test" />
<file name="bug12842_b.txt" role="test" />
<file name="bug13117.txt" role="test" />
<file name="deeply_nested.txt" role="test" />
<file name="flowed_msg.txt" role="test" />
<file name="header_trailing_ws.txt" role="test" />
Expand Down Expand Up @@ -573,6 +574,7 @@
<install as="Horde/Mime/fixtures/bug12536.txt" name="test/Horde/Mime/fixtures/bug12536.txt" />
<install as="Horde/Mime/fixtures/bug12842_a.txt" name="test/Horde/Mime/fixtures/bug12842_a.txt" />
<install as="Horde/Mime/fixtures/bug12842_b.txt" name="test/Horde/Mime/fixtures/bug12842_b.txt" />
<install as="Horde/Mime/fixtures/bug13117.txt" name="test/Horde/Mime/fixtures/bug13117.txt" />
<install as="Horde/Mime/fixtures/deeply_nested.txt" name="test/Horde/Mime/fixtures/deeply_nested.txt" />
<install as="Horde/Mime/fixtures/flowed_msg.txt" name="test/Horde/Mime/fixtures/flowed_msg.txt" />
<install as="Horde/Mime/fixtures/header_trailing_ws.txt" name="test/Horde/Mime/fixtures/header_trailing_ws.txt" />
Expand Down Expand Up @@ -1279,10 +1281,10 @@
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2014-03-16</date>
<date>2014-04-22</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix Horde_Mime_Part#buildMimeIds() when called on the base embedded object of a parent part (Bug #13117).
</notes>
</release>
</changelog>
Expand Down
20 changes: 20 additions & 0 deletions framework/Mime/test/Horde/Mime/PartTest.php
Expand Up @@ -362,6 +362,26 @@ public function testBug12842()
$this->assertTrue(isset($part['2']));
}

public function testBug13117()
{
$msg = file_get_contents(__DIR__ . '/fixtures/bug13117.txt');
$part = Horde_Mime_Part::parseMessage($msg);

$this->assertTrue(isset($part['2']));
$this->assertTrue(isset($part['2.0']));
$this->assertTrue(isset($part['2.1']));
$this->assertFalse(isset($part['2.2']));

$multipart = $part['2.0'];
$multipart->addPart(new Horde_Mime_Part());
$multipart->buildMimeIds('2.0');

$this->assertTrue(isset($part['2']));
$this->assertTrue(isset($part['2.0']));
$this->assertTrue(isset($part['2.1']));
$this->assertTrue(isset($part['2.2']));
}

protected function _getTestPart()
{
$part = new Horde_Mime_Part();
Expand Down
34 changes: 34 additions & 0 deletions framework/Mime/test/Horde/Mime/fixtures/bug13117.txt
@@ -0,0 +1,34 @@
Return-Path: <test@example.com>
Delivered-To: foo@example.com
Received: from localhost (localhost [127.0.0.1])
by example.com (Postfix) with ESMTP id 87C5B4F220
for <foo@example.com>; Tue, 7 Jul 2009 11:51:18 -0600 (MDT)
Message-ID: <20090707115118.ooc4wo40oc88@example.com>
Date: Tue, 07 Jul 2009 11:51:18 -0600
From: "Test Q. User" <test@example.com>
To: foo@example.com
Subject: Fwd: Test
User-Agent: Internet Messaging Program (IMP) H4 (5.0-git)
Content-Type: multipart/mixed; Boundary="=_123"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

--=_123
Content-Type: text/plain

Test.

--=_123
Content-Type: message/rfc822

From: "Foo" <test2@example.com>
Content-Type: multipart/mixed; Boundary="=_456"
MIME-Version: 1.0

--=_456
Content-Type: text/plain

Test 2.

--=_456--
--=_123--

0 comments on commit e2e1e3c

Please sign in to comment.