Fix base64 check missing '/' as valid character

* Issue introduced in 558cb3d
* Corrects loading of legacy KeePass Key Files that included a '/' in their data section. Fix #2863 and Fix #2834
This commit is contained in:
Jonathan White 2019-03-25 08:40:55 -04:00
parent bc3a7522a2
commit d6324feafd
2 changed files with 2 additions and 1 deletions

View File

@ -205,7 +205,7 @@ namespace Tools
bool isBase64(const QByteArray& ba)
{
constexpr auto pattern = R"(^(?:[a-z0-9+]{4})*(?:[a-z0-9+]{3}=|[a-z0-9+]{2}==)?$)";
constexpr auto pattern = R"(^(?:[a-z0-9+/]{4})*(?:[a-z0-9+/]{3}=|[a-z0-9+/]{2}==)?$)";
QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::RegExp2);
QString base64 = QString::fromLatin1(ba.constData(), ba.size());

View File

@ -59,6 +59,7 @@ void TestTools::testIsBase64()
QVERIFY(Tools::isBase64(QByteArray("12==")));
QVERIFY(Tools::isBase64(QByteArray("abcd9876MN==")));
QVERIFY(Tools::isBase64(QByteArray("abcd9876DEFGhijkMNO=")));
QVERIFY(Tools::isBase64(QByteArray("abcd987/DEFGh+jk/NO=")));
QVERIFY(not Tools::isBase64(QByteArray("abcd123==")));
QVERIFY(not Tools::isBase64(QByteArray("abc_")));
QVERIFY(not Tools::isBase64(QByteArray("123")));