Format uid string correctly when creating keys.
Correct format : name <email> (comment) Was : name <email> comment Though the 'comment' part was visible with the cli gpg app, it was not shown in kleopatra and in K7.
This commit is contained in:
@@ -17,9 +17,11 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#define SPACE " "
|
#define SPACE string(" ")
|
||||||
#define LESSTHAN "<"
|
#define LESSTHAN string("<")
|
||||||
#define MORETHAN ">"
|
#define MORETHAN string(">")
|
||||||
|
#define LEFT_PARENTHESIS string("(")
|
||||||
|
#define RIGHT_PARENTHESIS string(")")
|
||||||
// From gpgme.h (C API), don't want to include it here for one const.
|
// From gpgme.h (C API), don't want to include it here for one const.
|
||||||
#define _CREATE_NOEXPIRE (1 << 13)
|
#define _CREATE_NOEXPIRE (1 << 13)
|
||||||
|
|
||||||
@@ -187,10 +189,7 @@ const Error GpgMEWorker::CreateKeyWithEngineDefaultAlgo(GpgME::Key& k,
|
|||||||
ctx->setPinentryMode(Context::PinentryMode::PinentryLoopback);
|
ctx->setPinentryMode(Context::PinentryMode::PinentryLoopback);
|
||||||
ctx->setPassphraseProvider(ppp);
|
ctx->setPassphraseProvider(ppp);
|
||||||
|
|
||||||
string uid = name + SPACE
|
const string uid =MakeUidString(name, email, comment);
|
||||||
+ LESSTHAN + email + MORETHAN;
|
|
||||||
if (!comment.empty())
|
|
||||||
uid += SPACE + comment;
|
|
||||||
uint flags = expires
|
uint flags = expires
|
||||||
? 0 : _CREATE_NOEXPIRE;
|
? 0 : _CREATE_NOEXPIRE;
|
||||||
|
|
||||||
@@ -218,10 +217,7 @@ const Error GpgMEWorker::CreateKey(GpgME::Key& k,
|
|||||||
ctx->setPinentryMode(Context::PinentryMode::PinentryLoopback);
|
ctx->setPinentryMode(Context::PinentryMode::PinentryLoopback);
|
||||||
ctx->setPassphraseProvider(ppp);
|
ctx->setPassphraseProvider(ppp);
|
||||||
|
|
||||||
string uid = name + SPACE
|
const string uid = MakeUidString(name, email, comment);
|
||||||
+ LESSTHAN + email + MORETHAN;
|
|
||||||
if (!comment.empty())
|
|
||||||
uid += SPACE + comment;
|
|
||||||
uint flags = expires
|
uint flags = expires
|
||||||
? 0 : _CREATE_NOEXPIRE;
|
? 0 : _CREATE_NOEXPIRE;
|
||||||
|
|
||||||
@@ -295,3 +291,12 @@ const Error GpgMEWorker::ExportPublicKey(const char* pattern, string& buffer)
|
|||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string GpgMEWorker::MakeUidString(const string& name, const string& email, const string& comment)
|
||||||
|
{
|
||||||
|
string uid = name + SPACE
|
||||||
|
+ LESSTHAN + email + MORETHAN;
|
||||||
|
if (!comment.empty())
|
||||||
|
uid += SPACE + LEFT_PARENTHESIS + comment + RIGHT_PARENTHESIS;
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|||||||
@@ -159,6 +159,9 @@ private:
|
|||||||
Context * m_ctx;
|
Context * m_ctx;
|
||||||
// GPG will fetch a password here.
|
// GPG will fetch a password here.
|
||||||
LoopbackPassphraseProvider * m_ppp;
|
LoopbackPassphraseProvider * m_ppp;
|
||||||
|
|
||||||
|
string MakeUidString(const string& name, const string& email,
|
||||||
|
const string& comment);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ void K7Main::DisplayUids(const WString& fullKeyID, bool secret)
|
|||||||
if (m_ttbUids->columnCount() == 1)
|
if (m_ttbUids->columnCount() == 1)
|
||||||
{
|
{
|
||||||
m_ttbUids->addColumn(TR("Email"), 200);
|
m_ttbUids->addColumn(TR("Email"), 200);
|
||||||
m_ttbUids->addColumn(TR("Trust"), 100);
|
m_ttbUids->addColumn(TR("Trust"), 110);
|
||||||
m_ttbUids->addColumn(TR("Comment"), 300);
|
m_ttbUids->addColumn(TR("Comment"), 300);
|
||||||
}
|
}
|
||||||
WTreeTableNode * rootNode = new WTreeTableNode(fullKeyID);
|
WTreeTableNode * rootNode = new WTreeTableNode(fullKeyID);
|
||||||
|
|||||||
Reference in New Issue
Block a user