jstedfast / gmime

A C/C++ MIME creation and parser library with support for S/MIME, PGP, and Unix mbox spools.
GNU Lesser General Public License v2.1
113 stars 36 forks source link

Prefer gpgme_user_id_t's address field over the email field #102

Closed dkg closed 3 years ago

dkg commented 3 years ago

GMimeCertificate's email field is typically populated from the email field of the highest-validity gpgme_user_id_t object.

But gpgme offers some confusing commentary on the gpgme_user_id_t, in particular:

char *email
  This is the email component of uid, if available.
char *address;
  The mail address (addr-spec from RFC-5322) of the user ID
  string. This is general the same as the email part of this
  structure but might be slightly different. If no mail address is
  available NULL is stored.

It's hard to say exactly what this difference means.

Experimenting with some certificates and gpgme 1.15.1, it looks to me like the differences between email and address are:

It looks to me like address gives us a more stable guarantee -- it's either NULL or an addr-spec, while email might vary between:

(maybe the email field could be NULL as well, but i haven't encountered that yet).

This patch prefers to populate the email field of GMimeCertificate from gpgme_user_id_t's address field, when it is present but differs from the email field.

coveralls commented 3 years ago

Coverage Status

Coverage decreased (-0.003%) to 70.46% when pulling 565bebad5e4ade8cfa6274919b8e4f647f35b129 on dkg:prefer-address-to-email into 6bff5288f9c108160dd56dd20a9c6608aa55f791 on jstedfast:master.