Fix reading non-ASCII passwords that are protected.

Closes #28
This commit is contained in:
Felix Geyer 2012-06-24 18:22:18 +02:00
parent f690522725
commit d0016bf6c4
3 changed files with 8 additions and 1 deletions

View File

@ -635,7 +635,7 @@ void KeePass2XmlReader::parseEntryString(Entry* entry)
if (isProtected && !value.isEmpty()) { if (isProtected && !value.isEmpty()) {
if (m_randomStream) { if (m_randomStream) {
value = m_randomStream->process(QByteArray::fromBase64(value.toAscii())); value = QString::fromUtf8(m_randomStream->process(QByteArray::fromBase64(value.toAscii())));
} }
else { else {
raiseError(9); raiseError(9);

View File

@ -43,6 +43,7 @@ void TestKeePass2Writer::initTestCase()
group->setUuid(Uuid::random()); group->setUuid(Uuid::random());
group->setNotes("I'm a note!"); group->setNotes("I'm a note!");
Entry* entry = new Entry(); Entry* entry = new Entry();
entry->setPassword(QString::fromUtf8("\xc3\xa4\xa3\xb6\xc3\xbc\xe9\x9b\xbb\xe7\xb4\x85"));
entry->setUuid(Uuid::random()); entry->setUuid(Uuid::random());
entry->attributes()->set("test", "protectedTest", true); entry->attributes()->set("test", "protectedTest", true);
QVERIFY(entry->attributes()->isProtected("test")); QVERIFY(entry->attributes()->isProtected("test"));
@ -93,6 +94,11 @@ void TestKeePass2Writer::testAttachments()
QCOMPARE(entry->attachments()->value("aaa.txt"), QByteArray("also an attachment")); QCOMPARE(entry->attachments()->value("aaa.txt"), QByteArray("also an attachment"));
} }
void TestKeePass2Writer::testNonAsciiPasswords()
{
QCOMPARE(m_dbTest->rootGroup()->entries()[0]->password(), m_dbOrg->rootGroup()->entries()[0]->password());
}
void TestKeePass2Writer::cleanupTestCase() void TestKeePass2Writer::cleanupTestCase()
{ {
delete m_dbOrg; delete m_dbOrg;

View File

@ -31,6 +31,7 @@ private Q_SLOTS:
void testBasic(); void testBasic();
void testProtectedAttributes(); void testProtectedAttributes();
void testAttachments(); void testAttachments();
void testNonAsciiPasswords();
void cleanupTestCase(); void cleanupTestCase();
private: private: