diff --git a/share/demo.kdbx b/share/demo.kdbx index 35fd79ce..053dc29d 100644 Binary files a/share/demo.kdbx and b/share/demo.kdbx differ diff --git a/src/core/CustomData.cpp b/src/core/CustomData.cpp index fb959e18..1fa2cb10 100644 --- a/src/core/CustomData.cpp +++ b/src/core/CustomData.cpp @@ -24,7 +24,7 @@ const QString CustomData::LastModified = QStringLiteral("_LAST_MODIFIED"); const QString CustomData::Created = QStringLiteral("_CREATED"); const QString CustomData::BrowserKeyPrefix = QStringLiteral("KPXC_BROWSER_"); const QString CustomData::BrowserLegacyKeyPrefix = QStringLiteral("Public Key: "); -const QString CustomData::ExcludeFromReports = QStringLiteral("KnownBad"); +const QString CustomData::ExcludeFromReportsLegacy = QStringLiteral("KnownBad"); CustomData::CustomData(QObject* parent) : ModifiableObject(parent) diff --git a/src/core/CustomData.h b/src/core/CustomData.h index 356d2c69..37d8ef55 100644 --- a/src/core/CustomData.h +++ b/src/core/CustomData.h @@ -51,7 +51,7 @@ public: static const QString Created; static const QString BrowserKeyPrefix; static const QString BrowserLegacyKeyPrefix; - static const QString ExcludeFromReports; + static const QString ExcludeFromReportsLegacy; // Pre-KDBX 4.1 signals: void aboutToBeAdded(const QString& key); diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index e7e000c2..e17b3210 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -46,6 +46,7 @@ Entry::Entry() m_data.iconNumber = DefaultIconNumber; m_data.autoTypeEnabled = true; m_data.autoTypeObfuscation = 0; + m_data.excludeFromReports = false; connect(m_attributes, &EntryAttributes::modified, this, &Entry::updateTotp); connect(m_attributes, &EntryAttributes::modified, this, &Entry::modified); @@ -219,13 +220,14 @@ const QSharedPointer& Entry::passwordHealth() bool Entry::excludeFromReports() const { - return customData()->contains(CustomData::ExcludeFromReports) - && customData()->value(CustomData::ExcludeFromReports) == TRUE_STR; + return m_data.excludeFromReports + || (customData()->contains(CustomData::ExcludeFromReportsLegacy) + && customData()->value(CustomData::ExcludeFromReportsLegacy) == TRUE_STR); } void Entry::setExcludeFromReports(bool state) { - customData()->set(CustomData::ExcludeFromReports, state ? TRUE_STR : FALSE_STR); + set(m_data.excludeFromReports, state); } /** @@ -1433,6 +1435,9 @@ bool EntryData::equals(const EntryData& other, CompareItemOptions options) const // The existance of TOTP has changed between these entries return false; } + if (::compare(excludeFromReports, other.excludeFromReports, options) != 0) { + return false; + } return true; } diff --git a/src/core/Entry.h b/src/core/Entry.h index 1fcd0957..8da09e53 100644 --- a/src/core/Entry.h +++ b/src/core/Entry.h @@ -65,6 +65,7 @@ struct EntryData TimeInfo timeInfo; QSharedPointer totpSettings; QSharedPointer passwordHealth; + bool excludeFromReports; bool operator==(const EntryData& other) const; bool operator!=(const EntryData& other) const; diff --git a/src/format/KdbxXmlReader.cpp b/src/format/KdbxXmlReader.cpp index 03a87ad5..b998668e 100644 --- a/src/format/KdbxXmlReader.cpp +++ b/src/format/KdbxXmlReader.cpp @@ -726,6 +726,10 @@ Entry* KdbxXmlReader::parseEntry(bool history) parseEntryString(entry); continue; } + if (m_xml.name() == "QualityCheck") { + entry->setExcludeFromReports(!readBool()); + continue; + } if (m_xml.name() == "Binary") { QPair ref = parseEntryBinary(entry); if (!ref.first.isEmpty() && !ref.second.isEmpty()) { @@ -747,6 +751,13 @@ Entry* KdbxXmlReader::parseEntry(bool history) } if (m_xml.name() == "CustomData") { parseCustomData(entry->customData()); + + // Upgrade pre-KDBX-4.1 password report exclude flag + if (entry->customData()->contains(CustomData::ExcludeFromReportsLegacy)) { + entry->setExcludeFromReports(entry->customData()->value(CustomData::ExcludeFromReportsLegacy) + == TRUE_STR); + entry->customData()->remove(CustomData::ExcludeFromReportsLegacy); + } continue; } skipCurrentElement(); diff --git a/src/format/KdbxXmlWriter.cpp b/src/format/KdbxXmlWriter.cpp index c71aa42b..a404fd3c 100644 --- a/src/format/KdbxXmlWriter.cpp +++ b/src/format/KdbxXmlWriter.cpp @@ -344,6 +344,9 @@ void KdbxXmlWriter::writeEntry(const Entry* entry) writeString("OverrideURL", entry->overrideUrl()); writeString("Tags", entry->tags()); writeTimes(entry->timeInfo()); + if (entry->excludeFromReports()) { + writeBool("QualityCheck", false); + } const QList attributesKeyList = entry->attributes()->keys(); for (const QString& key : attributesKeyList) {