Fix broken browser integration since #6899 (#7030)

This commit is contained in:
Chih-Hsuan Yen 2021-10-09 23:22:44 +08:00 committed by GitHub
parent f2aa32c7b0
commit 3b3bc42e10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -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;
} }

View File

@ -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));
} }