Raise error when required xml elements are missing.

This commit is contained in:
Felix Geyer 2013-04-20 18:30:24 +02:00
parent e99e3ae6ca
commit 3be7fa6b3b

View File

@ -328,6 +328,9 @@ void KeePass2XmlReader::parseIcon()
if (uuidSet && iconSet) {
m_meta->addCustomIcon(uuid, icon);
}
else {
raiseError(20);
}
}
void KeePass2XmlReader::parseBinaries()
@ -401,6 +404,9 @@ void KeePass2XmlReader::parseCustomDataItem()
if (keySet && valueSet) {
m_meta->addCustomField(key, value);
}
else {
raiseError(21);
}
}
void KeePass2XmlReader::parseRoot()
@ -528,11 +534,16 @@ Group* KeePass2XmlReader::parseGroup()
}
}
Group* tmpGroup = group;
group = getGroup(tmpGroup->uuid());
group->copyDataFrom(tmpGroup);
group->setUpdateTimeinfo(false);
delete tmpGroup;
if (!group->uuid().isNull()) {
Group* tmpGroup = group;
group = getGroup(tmpGroup->uuid());
group->copyDataFrom(tmpGroup);
group->setUpdateTimeinfo(false);
delete tmpGroup;
}
else {
raiseError(22);
}
Q_FOREACH (Group* child, children) {
child->setParent(group);
@ -583,7 +594,12 @@ void KeePass2XmlReader::parseDeletedObject()
}
}
m_db->addDeletedObject(delObj);
if (!delObj.uuid.isNull() && !delObj.deletionTime.isNull()) {
m_db->addDeletedObject(delObj);
}
else {
raiseError(23);
}
}
Entry* KeePass2XmlReader::parseEntry(bool history)
@ -660,7 +676,10 @@ Entry* KeePass2XmlReader::parseEntry(bool history)
}
}
if (history) {
if (entry->uuid().isNull()) {
raiseError(24);
}
else if (history) {
entry->setUpdateTimeinfo(false);
}
else {
@ -726,6 +745,9 @@ void KeePass2XmlReader::parseEntryString(Entry* entry)
if (keySet && valueSet) {
entry->attributes()->set(key, value, protect);
}
else {
raiseError(25);
}
}
QPair<QString, QString> KeePass2XmlReader::parseEntryBinary(Entry* entry)
@ -760,9 +782,9 @@ QPair<QString, QString> KeePass2XmlReader::parseEntryBinary(Entry* entry)
if (isProtected && !value.isEmpty()) {
m_randomStream->processInPlace(value);
}
valueSet = true;
}
valueSet = true;
}
else {
skipCurrentElement();
@ -772,6 +794,9 @@ QPair<QString, QString> KeePass2XmlReader::parseEntryBinary(Entry* entry)
if (keySet && valueSet) {
entry->attachments()->set(key, value);
}
else {
raiseError(26);
}
return poolRef;
}
@ -824,6 +849,9 @@ void KeePass2XmlReader::parseAutoTypeAssoc(Entry* entry)
if (windowSet && sequenceSet) {
entry->autoTypeAssociations()->add(assoc);
}
else {
raiseError(27);
}
}
QList<Entry*> KeePass2XmlReader::parseEntryHistory()