Currently ContentID is just a simple data container object. I think it needs the following features at least:
When it is constructed:
It should be validated as url-addr-spec
When it is represented as a header:
It should be enclosed with < and >
Its domain-part should be idn-encoded
When it is represended as a CID-URL:
It should be prefixed with cid:
Its local-part should be percent-encoded
Its domain-part should be idn-encoded
However, it may break backward compatibility. To avoid it, static helper method is preferred.
$contentId = ContentID::fromUrlAddress("画像01@example.みんな"); // equivalent to new ContentID("<画像01@example.xn--q9jyb4c>")
// external interfaces for building HTML
$contentId->getCidUrl(); // returns "cid:%E7%94%BB%E5%83%8F01@example.xn--q9jyb4c"
$embeddedImage->getContentId()->getCidUrl(); // returns "cid:%E7%94%BB%E5%83%8F01@example.xn--q9jyb4c"
Citations from RFC 2392:
The URLs take the form
content-id = url-addr-spec
message-id = url-addr-spec
url-addr-spec = addr-spec ; URL encoding of RFC 822 addr-spec
cid-url = "cid" ":" content-id
mid-url = "mid" ":" message-id [ "/" content-id ]
A "cid" URL is converted to the corresponding Content-ID message
header [MIME] by removing the "cid:" prefix, converting the % encoded
character to their equivalent US-ASCII characters, and enclosing the
remaining parts with an angle bracket pair, "<" and ">". For
example, "cid:foo4%25foo1@bar.net" corresponds to
Content-ID: <foo4%25foo1@bar.net>
Reversing the process and converting URL special characters to their
% encodings produces the original cid.
(I think the example is wrong; Content-ID: <foo4%foo1@bar.net> seems to be correct)
I'm afraid that I'm not so familiar with RFC details...
Good catch! Reading RFCs is a hell of a job. I can tell that from the experience of this library. I will also have a look at the RFC and see what we can do to stay in line with it without breaking BC.
Currently
ContentID
is just a simple data container object. I think it needs the following features at least:url-addr-spec
<
and>
cid:
However, it may break backward compatibility. To avoid it, static helper method is preferred.
Citations from RFC 2392:
(I think the example is wrong;
Content-ID: <foo4%foo1@bar.net>
seems to be correct)I'm afraid that I'm not so familiar with RFC details...