mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-05 21:14:20 -04:00
Use existing base64 check in Tools namespace
This commit is contained in:
parent
e786291086
commit
52d411f423
1 changed files with 1 additions and 3 deletions
|
@ -1028,10 +1028,8 @@ bool KdbxXmlReader::readBool()
|
||||||
|
|
||||||
QDateTime KdbxXmlReader::readDateTime()
|
QDateTime KdbxXmlReader::readDateTime()
|
||||||
{
|
{
|
||||||
static QRegularExpression b64regex("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$");
|
|
||||||
QString str = readString();
|
QString str = readString();
|
||||||
|
if (Tools::isBase64(str.toLatin1())) {
|
||||||
if (b64regex.match(str).hasMatch()) {
|
|
||||||
QByteArray secsBytes = QByteArray::fromBase64(str.toUtf8()).leftJustified(8, '\0', true).left(8);
|
QByteArray secsBytes = QByteArray::fromBase64(str.toUtf8()).leftJustified(8, '\0', true).left(8);
|
||||||
qint64 secs = Endian::bytesToSizedInt<quint64>(secsBytes, KeePass2::BYTEORDER);
|
qint64 secs = Endian::bytesToSizedInt<quint64>(secsBytes, KeePass2::BYTEORDER);
|
||||||
return QDateTime(QDate(1, 1, 1), QTime(0, 0, 0, 0), Qt::UTC).addSecs(secs);
|
return QDateTime(QDate(1, 1, 1), QTime(0, 0, 0, 0), Qt::UTC).addSecs(secs);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue