Raise an error when parsing duplicate attributes/attachments.

This commit is contained in:
Felix Geyer 2014-12-03 23:36:53 +01:00
parent 3ea0592b53
commit eb22f0a2d8

View File

@ -825,7 +825,13 @@ void KeePass2XmlReader::parseEntryString(Entry* entry)
}
if (keySet && valueSet) {
entry->attributes()->set(key, value, protect);
// the default attributes are always there so additionally check if it's empty
if (entry->attributes()->hasKey(key) && !entry->attributes()->value(key).isEmpty()) {
raiseError("Duplicate custom attribute found");
}
else {
entry->attributes()->set(key, value, protect);
}
}
else {
raiseError("Entry string key or value missing");
@ -874,7 +880,12 @@ QPair<QString, QString> KeePass2XmlReader::parseEntryBinary(Entry* entry)
}
if (keySet && valueSet) {
entry->attachments()->set(key, value);
if (entry->attachments()->hasKey(key)) {
raiseError("Duplicate attachment found");
}
else {
entry->attachments()->set(key, value);
}
}
else {
raiseError("Entry binary key or value missing");