After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 762782 - g_mime_object_get_content_id removes a trailing period of the Content-Id
g_mime_object_get_content_id removes a trailing period of the Content-Id
Status: RESOLVED NOTABUG
Product: gmime
Classification: Other
Component: general
2.6.x
Other Linux
: Normal normal
: ---
Assigned To: Jeffrey Stedfast
Jeffrey Stedfast
Depends on:
Blocks:
 
 
Reported: 2016-02-27 17:41 UTC by Ralph Plawetzki
Modified: 2017-12-02 10:49 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ralph Plawetzki 2016-02-27 17:41:33 UTC
GMime is used in elementary OS Mail for parsing the mime parts of email messages.
Parsing one message though failed as it contains the following inline image:

--Apple-Mail=_B323DF20-A4A1-404B-93B0-04F8B3CEB00C
Content-Transfer-Encoding: base64
Content-Disposition: inline;
	filename=128x128_blue.png
Content-Type: image/png;
	x-unix-mode=0644;
	name="128x128_blue.png"
Content-Id: <F79E1B9F-4ECC-41D1-A5F6-B6057DC67E38@hsd1.ca.comcast.net.>

Please note the trailing period at the end of the Content-Id.

An analysis showed that g_mime_part_get_content_id returns the Content-Id without the trailing period.

This seems wrong as the Content-Id should be treated as it is (including the period at the end).
Comment 1 Ralph Plawetzki 2016-02-29 19:27:44 UTC
Thread 1 "pantheon-mail" hit Breakpoint 2, g_mime_decode_domain (in=in@entry=0x7fffffffdf78, domain=domain@entry=0xc724e0)
    at gmime-parse-utils.c:289
289						g_string_truncate (domain, domain->len - 1);
(gdb) p *(GString *) domain
$6 = {str = 0x15b2f90 "F79E1B9F-4ECC-41D1-A5F6-B6057DC67E38@hsd1.ca.comcast.net.", len = 57, allocated_len = 64}
(gdb)
Comment 2 Jeffrey Stedfast 2016-03-03 14:07:42 UTC
I would argue that this is not a bug because it is canonicalizing the Content-Id value which is what you want.

The reason that you want to canonicalize the value is because it is the only way to compare the value with something else, such as a cid: url or with the value of a start parameter on a multipart/related.

Of course, you also need to canonicalize the cid: and start parameter values as well.

But without doing so, you will not be able to get proper matching.

For example, let's say I have the following Content-Id header:

Content-Id: <F79E1B9F (comment) .
  (comment) 4ECC.41D1. (comment)A5F6 
  (comment).B6057DC67E38 (comment) @
  (comment) hsd1.ca.comcast.net.>

The cid: url cannot have comments, so it would look like this:

cid:F79E1B9F.4ECC.41D1.A5F6.B6057DC67E38@hsd1.ca.comcast.net

or, potentially, like this:

cid:F79E1B9F.4ECC.41D1.A5F6.B6057DC67E38@hsd1.ca.comcast.net.

But if you read the specifications for URLs, you'll find that there, too, a hostname that ends with a '.', while valid, is the same as the hostname without the trailing '.', so if you canonicalize the value, you get: "F79E1B9F.4ECC.41D1.A5F6.B6057DC67E38@hsd1.ca.comcast.net"

Hope that helps to explain why the code does what it does.
Comment 3 Ralph Plawetzki 2016-03-03 16:18:52 UTC
Yes, with your explanation I can understand your point of view and GMime has to be universally applicable of course.
Comment 4 Michael Gratton 2017-12-02 10:49:52 UTC
Re-opened on github: https://github.com/jstedfast/gmime/issues/38