Commit 9bc72ccb authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Force the entered expiration date into the allowed range

This is a quick fix. A proper fix should show an error if the date is
outside of the allowed range.

GnuPG-bug-id: 5864
parent 876a5306
Pipeline #172072 passed with stage
in 2 minutes and 45 seconds
......@@ -667,19 +667,23 @@ public:
return ui.authenticationCB->isChecked();
}
QDate forceDateIntoAllowedRange(QDate date) const
{
const auto minDate = ui.expiryDE->minimumDate();
if (minDate.isValid() && date < minDate) {
date = minDate;
}
const auto maxDate = ui.expiryDE->maximumDate();
if (maxDate.isValid() && date > maxDate) {
date = maxDate;
}
return date;
}
void setExpiryDate(QDate date)
{
if (date.isValid()) {
// force the date into the allowed range
const auto minDate = ui.expiryDE->minimumDate();
if (minDate.isValid() && date < minDate) {
date = minDate;
}
const auto maxDate = ui.expiryDE->maximumDate();
if (maxDate.isValid() && date > maxDate) {
date = maxDate;
}
ui.expiryDE->setDate(date);
ui.expiryDE->setDate(forceDateIntoAllowedRange(date));
} else {
// check if unlimited validity is allowed
if (unlimitedValidityIsAllowed()) {
......@@ -692,7 +696,7 @@ public:
}
QDate expiryDate() const
{
return ui.expiryCB->isChecked() ? ui.expiryDE->date() : QDate();
return ui.expiryCB->isChecked() ? forceDateIntoAllowedRange(ui.expiryDE->date()) : QDate();
}
Q_SIGNALS:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment