aboutsummaryrefslogtreecommitdiffstats
path: root/src/m_key_server_sync/SearchKeyDialog.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2026-08-03 15:40:32 +0200
committersaturneric <[email protected]>2026-08-03 15:40:32 +0200
commit4c8f8eeac158ba0a6b4dda02ca6972222357aa1c (patch)
tree0ed78c651c02b129a3d3e31831c3325c3bb7280a /src/m_key_server_sync/SearchKeyDialog.cpp
parentfeat(key_server_sync): prefer VKS for sync and support v6 keys (diff)
downloadmodules-4c8f8eeac158ba0a6b4dda02ca6972222357aa1c.tar.gz
modules-4c8f8eeac158ba0a6b4dda02ca6972222357aa1c.zip
fix(pks): fix keyserver display for sizes, dates, and uids
- make key size output show curve names for ECC algorithms - parse numeric key_size and return "-" for missing/zero bits - avoid printing "0 bits" for fixed-param algos; show real bits - add FormatKeyServerDate to render timestamps and avoid 1970-01-01 - show "Unknown" / "Never" for absent creation/expiration dates - display "(no user ID published)" for empty or withheld uids
Diffstat (limited to 'src/m_key_server_sync/SearchKeyDialog.cpp')
-rw-r--r--src/m_key_server_sync/SearchKeyDialog.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/m_key_server_sync/SearchKeyDialog.cpp b/src/m_key_server_sync/SearchKeyDialog.cpp
index 5faf8ca..e19e28d 100644
--- a/src/m_key_server_sync/SearchKeyDialog.cpp
+++ b/src/m_key_server_sync/SearchKeyDialog.cpp
@@ -58,6 +58,20 @@ auto ShortenKeyHandle(const QString& handle) -> QString {
return handle;
}
+/// Render a keyserver timestamp.
+///
+/// The machine-readable format leaves a field empty to mean the date does not
+/// apply — a key with no expiry sends nothing at all. Feeding that straight to
+/// fromSecsSinceEpoch() printed 1970-01-01, which reads as an expired key.
+auto FormatKeyServerDate(const QString& seconds, const QString& absent)
+ -> QString {
+ bool ok = false;
+ const auto value = seconds.toLongLong(&ok);
+ if (!ok || value <= 0) return absent;
+
+ return QLocale().toString(QDateTime::fromSecsSinceEpoch(value), "yyyy-MM-dd");
+}
+
} // namespace
SearchKeyDialog::SearchKeyDialog(QWidget* parent)
@@ -281,17 +295,19 @@ void SearchKeyDialog::slot_search_finished_pks(
ui_->tableWidget->setItem(row, 0, keyid_item);
auto uid = key.uids.isEmpty() ? KeyServerUID() : key.uids.first();
- auto* uid_item = new QTableWidgetItem(uid.uid);
+ // A key can legitimately come back with no identity attached: verifying
+ // key servers withhold user IDs until the address has been confirmed. An
+ // empty cell would read as a parsing failure.
+ auto* uid_item = new QTableWidgetItem(
+ uid.uid.trimmed().isEmpty() ? tr("(no user ID published)") : uid.uid);
ui_->tableWidget->setItem(row, 1, uid_item);
- auto* creation_date_item = new QTableWidgetItem(QLocale().toString(
- QDateTime::fromSecsSinceEpoch(key.creation_date.toLongLong()),
- "yyyy-MM-dd"));
+ auto* creation_date_item = new QTableWidgetItem(
+ FormatKeyServerDate(key.creation_date, tr("Unknown")));
ui_->tableWidget->setItem(row, 2, creation_date_item);
- auto* expiration_date_item = new QTableWidgetItem(QLocale().toString(
- QDateTime::fromSecsSinceEpoch(key.expiration_date.toLongLong()),
- "yyyy-MM-dd"));
+ auto* expiration_date_item = new QTableWidgetItem(
+ FormatKeyServerDate(key.expiration_date, tr("Never")));
ui_->tableWidget->setItem(row, 3, expiration_date_item);
auto* algo_item = new QTableWidgetItem(key.algorithm_desc);