mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-14 00:39:53 -05:00
parent
f2aa32c7b0
commit
3b3bc42e10
@ -324,7 +324,7 @@ namespace Tools
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto uuid = hexToUuid(uuidStr);
|
const auto uuid = hexToUuid(uuidStr);
|
||||||
if (uuid.isNull() || uuid.version() == QUuid::VerUnknown) {
|
if (uuid.isNull()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ void TestTools::testHumanReadableFileSize()
|
|||||||
void TestTools::testIsHex()
|
void TestTools::testIsHex()
|
||||||
{
|
{
|
||||||
QVERIFY(Tools::isHex("0123456789abcdefABCDEF"));
|
QVERIFY(Tools::isHex("0123456789abcdefABCDEF"));
|
||||||
QVERIFY(not Tools::isHex(QByteArray("0xnothex")));
|
QVERIFY(!Tools::isHex(QByteArray("0xnothex")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTools::testIsBase64()
|
void TestTools::testIsBase64()
|
||||||
@ -59,9 +59,9 @@ void TestTools::testIsBase64()
|
|||||||
QVERIFY(Tools::isBase64(QByteArray("abcd9876MN==")));
|
QVERIFY(Tools::isBase64(QByteArray("abcd9876MN==")));
|
||||||
QVERIFY(Tools::isBase64(QByteArray("abcd9876DEFGhijkMNO=")));
|
QVERIFY(Tools::isBase64(QByteArray("abcd9876DEFGhijkMNO=")));
|
||||||
QVERIFY(Tools::isBase64(QByteArray("abcd987/DEFGh+jk/NO=")));
|
QVERIFY(Tools::isBase64(QByteArray("abcd987/DEFGh+jk/NO=")));
|
||||||
QVERIFY(not Tools::isBase64(QByteArray("abcd123==")));
|
QVERIFY(!Tools::isBase64(QByteArray("abcd123==")));
|
||||||
QVERIFY(not Tools::isBase64(QByteArray("abc_")));
|
QVERIFY(!Tools::isBase64(QByteArray("abc_")));
|
||||||
QVERIFY(not Tools::isBase64(QByteArray("123")));
|
QVERIFY(!Tools::isBase64(QByteArray("123")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTools::testEnvSubstitute()
|
void TestTools::testEnvSubstitute()
|
||||||
@ -92,16 +92,19 @@ void TestTools::testEnvSubstitute()
|
|||||||
void TestTools::testValidUuid()
|
void TestTools::testValidUuid()
|
||||||
{
|
{
|
||||||
auto validUuid = Tools::uuidToHex(QUuid::createUuid());
|
auto validUuid = Tools::uuidToHex(QUuid::createUuid());
|
||||||
auto nonValidUuid = "1234567890abcdef1234567890abcdef";
|
auto nonRfc4122Uuid = "1234567890abcdef1234567890abcdef";
|
||||||
auto emptyUuid = QString();
|
auto emptyUuid = QString();
|
||||||
auto shortUuid = validUuid.left(10);
|
auto shortUuid = validUuid.left(10);
|
||||||
auto longUuid = validUuid + "baddata";
|
auto longUuid = validUuid + "baddata";
|
||||||
auto nonHexUuid = Tools::uuidToHex(QUuid::createUuid()).replace(0, 1, 'p');
|
auto nonHexUuid = Tools::uuidToHex(QUuid::createUuid()).replace(0, 1, 'p');
|
||||||
|
|
||||||
QVERIFY(Tools::isValidUuid(validUuid));
|
QVERIFY(Tools::isValidUuid(validUuid));
|
||||||
QVERIFY(not Tools::isValidUuid(nonValidUuid));
|
/* Before https://github.com/keepassxreboot/keepassxc/pull/1770/, entry
|
||||||
QVERIFY(not Tools::isValidUuid(emptyUuid));
|
* UUIDs are simply random 16-byte strings. Such older entries should be
|
||||||
QVERIFY(not Tools::isValidUuid(shortUuid));
|
* accepted as well. */
|
||||||
QVERIFY(not Tools::isValidUuid(longUuid));
|
QVERIFY(Tools::isValidUuid(nonRfc4122Uuid));
|
||||||
QVERIFY(not Tools::isValidUuid(nonHexUuid));
|
QVERIFY(!Tools::isValidUuid(emptyUuid));
|
||||||
|
QVERIFY(!Tools::isValidUuid(shortUuid));
|
||||||
|
QVERIFY(!Tools::isValidUuid(longUuid));
|
||||||
|
QVERIFY(!Tools::isValidUuid(nonHexUuid));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user