aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2015-05-27 15:05:51 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2015-05-27 15:07:51 +0200
commita8bbbfc79e878d82045006c6793e0b9707450823 (patch)
tree45a5004767fa407370a4aa5ba1771f4654f23910
parente2c9276de78cb08cd614f8072a5e9afa03c973bd (diff)
downloadMail-a8bbbfc79e878d82045006c6793e0b9707450823.zip
Mail-a8bbbfc79e878d82045006c6793e0b9707450823.tar.gz
Mail-a8bbbfc79e878d82045006c6793e0b9707450823.tar.bz2
Content-ID must surrounded by `<` and `>`.
In RFC2392, Section 2, we must not miss this part: > … and enclosing the remaining parts with an angle bracket pair, "<" > and ">".
-rw-r--r--Content/Content.php4
-rw-r--r--Test/Unit/Content/Content.php8
2 files changed, 7 insertions, 5 deletions
diff --git a/Content/Content.php b/Content/Content.php
index bd6d597..54bcd6d 100644
--- a/Content/Content.php
+++ b/Content/Content.php
@@ -192,10 +192,10 @@ abstract class Content implements \ArrayAccess
public function getId()
{
if (!isset($this['content-id'])) {
- $this['content-id'] = md5(uniqid()) . '*mail@hoa-project.net';
+ $this['content-id'] = '<' . md5(uniqid()) . '*mail@hoa-project.net>';
}
- return $this['content-id'];
+ return trim($this['content-id'], '<>');
}
/**
diff --git a/Test/Unit/Content/Content.php b/Test/Unit/Content/Content.php
index 0b93f51..3b38e78 100644
--- a/Test/Unit/Content/Content.php
+++ b/Test/Unit/Content/Content.php
@@ -183,21 +183,23 @@ class Content extends Test\Unit\Suite
->when($result = $content->getId())
->then
->string($result)
- ->isEqualTo('foo*mail@hoa-project.net');
+ ->isEqualTo('foo*mail@hoa-project.net')
+ ->string($content['content-id'])
+ ->isEqualTo('<foo*mail@hoa-project.net>');
}
public function case_get_id_forced()
{
$this
->given(
- $id = 'foo@bar.baz',
+ $id = '<foo@bar.baz>',
$content = new SUT(),
$content['content-id'] = $id
)
->when($result = $content->getId())
->then
->string($result)
- ->isEqualTo($id);
+ ->isEqualTo(trim($id, '<>'));
}
public function case_get_id_url()