From 85e05537e15346896a271d3f62bead9dd7e3f180 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Thu, 15 Dec 2016 11:31:14 +0100 Subject: [PATCH] cpp: Fix addrSpec for keys without email * lang/cpp/src/key.cpp (UserID::addrSpec): Use uid->address instead of normalizing again. (&operator<<(std::ostream &, const UserID &): Print it. -- This saves a normalization and fixes the case where a user id is just a mail address without name, in that case gpgme sets "address" but not email. Because the email is then the name. --- lang/cpp/src/key.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index 235a3c8e..d621a81e 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -894,7 +894,11 @@ std::string UserID::addrSpecFromString(const char *userid) std::string UserID::addrSpec() const { - return addrSpecFromString(email()); + if (!uid || !uid->address) { + return std::string(); + } + + return uid->address; } std::ostream &operator<<(std::ostream &os, const UserID &uid) @@ -903,6 +907,7 @@ std::ostream &operator<<(std::ostream &os, const UserID &uid) if (!uid.isNull()) { os << "\n name: " << protect(uid.name()) << "\n email: " << protect(uid.email()) + << "\n mbox: " << uid.addrSpec() << "\n comment: " << protect(uid.comment()) << "\n validity: " << uid.validityAsString() << "\n revoked: " << uid.isRevoked()