mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-01 19:16:16 -04:00
Merge branch '2.0'
This commit is contained in:
commit
d6d92ce90a
20 changed files with 382 additions and 176 deletions
|
@ -901,10 +901,10 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
|
|||
QByteArray entryUuid = data.mid(pos, 16);
|
||||
pos += 16;
|
||||
|
||||
int iconId = Endian::bytesToUInt32(data.mid(pos, 4), KeePass1::BYTEORDER);
|
||||
quint32 iconId = Endian::bytesToUInt32(data.mid(pos, 4), KeePass1::BYTEORDER);
|
||||
pos += 4;
|
||||
|
||||
if (m_entryUuids.contains(entryUuid) && (iconId < iconUuids.size())) {
|
||||
if (m_entryUuids.contains(entryUuid) && (iconId < static_cast<quint32>(iconUuids.size()))) {
|
||||
m_entryUuids[entryUuid]->setIcon(iconUuids[iconId]);
|
||||
}
|
||||
}
|
||||
|
@ -917,10 +917,10 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
|
|||
quint32 groupId = Endian::bytesToUInt32(data.mid(pos, 4), KeePass1::BYTEORDER);
|
||||
pos += 4;
|
||||
|
||||
int iconId = Endian::bytesToUInt32(data.mid(pos, 4), KeePass1::BYTEORDER);
|
||||
quint32 iconId = Endian::bytesToUInt32(data.mid(pos, 4), KeePass1::BYTEORDER);
|
||||
pos += 4;
|
||||
|
||||
if (m_groupIds.contains(groupId) && (iconId < iconUuids.size())) {
|
||||
if (m_groupIds.contains(groupId) && (iconId < static_cast<quint32>(iconUuids.size()))) {
|
||||
m_groupIds[groupId]->setIcon(iconUuids[iconId]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ KeePass2Repair::RepairResult KeePass2Repair::repairDatabase(QIODevice* device, c
|
|||
|
||||
// try to fix broken databases because of bug #392
|
||||
for (int i = (xmlData.size() - 1); i >= 0; i--) {
|
||||
char ch = xmlData.at(i);
|
||||
quint8 ch = static_cast<quint8>(xmlData.at(i));
|
||||
if (ch < 0x20 && ch != 0x09 && ch != 0x0A && ch != 0x0D) {
|
||||
xmlData.remove(i, 1);
|
||||
repairAction = true;
|
||||
|
|
|
@ -523,6 +523,7 @@ Group* KeePass2XmlReader::parseGroup()
|
|||
if (m_strictMode) {
|
||||
raiseError("Invalid group icon number");
|
||||
}
|
||||
iconId = 0;
|
||||
}
|
||||
else {
|
||||
if (iconId >= DatabaseIcons::IconCount) {
|
||||
|
@ -702,6 +703,7 @@ Entry* KeePass2XmlReader::parseEntry(bool history)
|
|||
if (m_strictMode) {
|
||||
raiseError("Invalid entry icon number");
|
||||
}
|
||||
iconId = 0;
|
||||
}
|
||||
else {
|
||||
entry->setIcon(iconId);
|
||||
|
|
|
@ -550,11 +550,19 @@ QString KeePass2XmlWriter::colorPartToString(int value)
|
|||
QString KeePass2XmlWriter::stripInvalidXml10Chars(QString str)
|
||||
{
|
||||
for (int i = str.size() - 1; i >= 0; i--) {
|
||||
const ushort uc = str.at(i).unicode();
|
||||
const QChar ch = str.at(i);
|
||||
const ushort uc = ch.unicode();
|
||||
|
||||
if ((uc < 0x20 && uc != 0x09 && uc != 0x0A && uc != 0x0D)
|
||||
|| (uc > 0xD7FF && uc < 0xE000)
|
||||
|| (uc > 0xFFFD))
|
||||
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 chracters
|
||||
|| (uc >= 0x7F && uc <= 0x84) // control chracters, valid but discouraged by XML
|
||||
|| (uc >= 0x86 && uc <= 0x9F) // control chracters, 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);
|
||||
|
|
|
@ -49,10 +49,6 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
|
|||
connect(m_ui->editPassword, SIGNAL(textChanged(QString)), SLOT(activatePassword()));
|
||||
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(activateKeyFile()));
|
||||
|
||||
connect(m_ui->checkPassword, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
|
||||
connect(m_ui->checkKeyFile, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
|
||||
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(setOkButtonEnabled()));
|
||||
|
||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase()));
|
||||
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
||||
}
|
||||
|
@ -75,6 +71,7 @@ void DatabaseOpenWidget::load(const QString& filename)
|
|||
}
|
||||
}
|
||||
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
m_ui->editPassword->setFocus();
|
||||
}
|
||||
|
||||
|
@ -99,9 +96,6 @@ void DatabaseOpenWidget::openDatabase()
|
|||
{
|
||||
KeePass2Reader reader;
|
||||
CompositeKey masterKey = databaseKey();
|
||||
if (masterKey.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFile file(m_filename);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
|
@ -172,14 +166,6 @@ void DatabaseOpenWidget::activateKeyFile()
|
|||
m_ui->checkKeyFile->setChecked(true);
|
||||
}
|
||||
|
||||
void DatabaseOpenWidget::setOkButtonEnabled()
|
||||
{
|
||||
bool enable = m_ui->checkPassword->isChecked()
|
||||
|| (m_ui->checkKeyFile->isChecked() && !m_ui->comboKeyFile->currentText().isEmpty());
|
||||
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable);
|
||||
}
|
||||
|
||||
void DatabaseOpenWidget::browseKeyFile()
|
||||
{
|
||||
QString filters = QString("%1 (*);;%2 (*.key)").arg(tr("All files"), tr("Key files"));
|
||||
|
|
|
@ -54,7 +54,6 @@ protected Q_SLOTS:
|
|||
private Q_SLOTS:
|
||||
void activatePassword();
|
||||
void activateKeyFile();
|
||||
void setOkButtonEnabled();
|
||||
void browseKeyFile();
|
||||
|
||||
protected:
|
||||
|
|
|
@ -51,6 +51,7 @@ void DatabaseRepairWidget::openDatabase()
|
|||
if (!key.load(keyFilename, &errorMsg)) {
|
||||
MessageBox::warning(this, tr("Error"), tr("Can't open key file").append(":\n").append(errorMsg));
|
||||
Q_EMIT editFinished(false);
|
||||
return;
|
||||
}
|
||||
masterKey.addKey(key);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue