mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Formatting the code.
This commit is contained in:
@@ -33,7 +33,10 @@ KdbxXmlWriter::KdbxXmlWriter(quint32 version)
|
||||
{
|
||||
}
|
||||
|
||||
void KdbxXmlWriter::writeDatabase(QIODevice* device, Database* db, KeePass2RandomStream* randomStream, const QByteArray& headerHash)
|
||||
void KdbxXmlWriter::writeDatabase(QIODevice* device,
|
||||
Database* db,
|
||||
KeePass2RandomStream* randomStream,
|
||||
const QByteArray& headerHash)
|
||||
{
|
||||
m_db = db;
|
||||
m_meta = db->metadata();
|
||||
@@ -64,7 +67,7 @@ void KdbxXmlWriter::writeDatabase(QIODevice* device, Database* db, KeePass2Rando
|
||||
void KdbxXmlWriter::writeDatabase(const QString& filename, Database* db)
|
||||
{
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::WriteOnly|QIODevice::Truncate);
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
writeDatabase(&file, db);
|
||||
}
|
||||
|
||||
@@ -204,8 +207,7 @@ void KdbxXmlWriter::writeBinaries()
|
||||
|
||||
buffer.seek(0);
|
||||
data = buffer.readAll();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
data = i.key();
|
||||
}
|
||||
|
||||
@@ -354,12 +356,12 @@ void KdbxXmlWriter::writeEntry(const Entry* entry)
|
||||
for (const QString& key : attributesKeyList) {
|
||||
m_xml.writeStartElement("String");
|
||||
|
||||
bool protect = ( ((key == "Title") && m_meta->protectTitle()) ||
|
||||
((key == "UserName") && m_meta->protectUsername()) ||
|
||||
((key == "Password") && m_meta->protectPassword()) ||
|
||||
((key == "URL") && m_meta->protectUrl()) ||
|
||||
((key == "Notes") && m_meta->protectNotes()) ||
|
||||
entry->attributes()->isProtected(key) );
|
||||
bool protect =
|
||||
(((key == "Title") && m_meta->protectTitle()) || ((key == "UserName") && m_meta->protectUsername())
|
||||
|| ((key == "Password") && m_meta->protectPassword())
|
||||
|| ((key == "URL") && m_meta->protectUrl())
|
||||
|| ((key == "Notes") && m_meta->protectNotes())
|
||||
|| entry->attributes()->isProtected(key));
|
||||
|
||||
writeString("Key", key);
|
||||
|
||||
@@ -375,13 +377,11 @@ void KdbxXmlWriter::writeEntry(const Entry* entry)
|
||||
raiseError(m_randomStream->errorString());
|
||||
}
|
||||
value = QString::fromLatin1(rawData.toBase64());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
m_xml.writeAttribute("ProtectInMemory", "True");
|
||||
value = entry->attributes()->value(key);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
value = entry->attributes()->value(key);
|
||||
}
|
||||
|
||||
@@ -462,8 +462,7 @@ void KdbxXmlWriter::writeString(const QString& qualifiedName, const QString& str
|
||||
{
|
||||
if (string.isEmpty()) {
|
||||
m_xml.writeEmptyElement(qualifiedName);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
m_xml.writeTextElement(qualifiedName, stripInvalidXml10Chars(string));
|
||||
}
|
||||
}
|
||||
@@ -477,8 +476,7 @@ void KdbxXmlWriter::writeBool(const QString& qualifiedName, bool b)
|
||||
{
|
||||
if (b) {
|
||||
writeString(qualifiedName, "True");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
writeString(qualifiedName, "False");
|
||||
}
|
||||
}
|
||||
@@ -513,8 +511,7 @@ void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const Group* group)
|
||||
{
|
||||
if (group) {
|
||||
writeUuid(qualifiedName, group->uuid());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
writeUuid(qualifiedName, Uuid());
|
||||
}
|
||||
}
|
||||
@@ -523,8 +520,7 @@ void KdbxXmlWriter::writeUuid(const QString& qualifiedName, const Entry* entry)
|
||||
{
|
||||
if (entry) {
|
||||
writeUuid(qualifiedName, entry->uuid());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
writeUuid(qualifiedName, Uuid());
|
||||
}
|
||||
}
|
||||
@@ -539,9 +535,8 @@ void KdbxXmlWriter::writeColor(const QString& qualifiedName, const QColor& color
|
||||
QString colorStr;
|
||||
|
||||
if (color.isValid()) {
|
||||
colorStr = QString("#%1%2%3").arg(colorPartToString(color.red()),
|
||||
colorPartToString(color.green()),
|
||||
colorPartToString(color.blue()));
|
||||
colorStr = QString("#%1%2%3").arg(
|
||||
colorPartToString(color.red()), colorPartToString(color.green()), colorPartToString(color.blue()));
|
||||
}
|
||||
|
||||
writeString(qualifiedName, colorStr);
|
||||
@@ -553,11 +548,9 @@ void KdbxXmlWriter::writeTriState(const QString& qualifiedName, Group::TriState
|
||||
|
||||
if (triState == Group::Inherit) {
|
||||
value = "null";
|
||||
}
|
||||
else if (triState == Group::Enable) {
|
||||
} else if (triState == Group::Enable) {
|
||||
value = "true";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
value = "false";
|
||||
}
|
||||
|
||||
@@ -583,13 +576,12 @@ QString KdbxXmlWriter::stripInvalidXml10Chars(QString str)
|
||||
if (ch.isLowSurrogate() && i != 0 && str.at(i - 1).isHighSurrogate()) {
|
||||
// keep valid surrogate pair
|
||||
i--;
|
||||
}
|
||||
else if ((uc < 0x20 && uc != 0x09 && uc != 0x0A && uc != 0x0D) // control characters
|
||||
|| (uc >= 0x7F && uc <= 0x84) // control characters, valid but discouraged by XML
|
||||
|| (uc >= 0x86 && uc <= 0x9F) // control characters, valid but discouraged by XML
|
||||
|| (uc > 0xFFFD) // noncharacter
|
||||
|| ch.isLowSurrogate() // single low surrogate
|
||||
|| ch.isHighSurrogate()) // single high surrogate
|
||||
} else if ((uc < 0x20 && uc != 0x09 && uc != 0x0A && uc != 0x0D) // control characters
|
||||
|| (uc >= 0x7F && uc <= 0x84) // control characters, valid but discouraged by XML
|
||||
|| (uc >= 0x86 && uc <= 0x9F) // control characters, valid but discouraged by XML
|
||||
|| (uc > 0xFFFD) // noncharacter
|
||||
|| ch.isLowSurrogate() // single low surrogate
|
||||
|| ch.isHighSurrogate()) // single high surrogate
|
||||
{
|
||||
qWarning("Stripping invalid XML 1.0 codepoint %x", uc);
|
||||
str.remove(i, 1);
|
||||
|
||||
Reference in New Issue
Block a user