mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(history): Strictly check public_key during database upgrade
Text comparisons in SQL are not case sensitive. Since we want to use this check to specifically check for case mismatch, cast to blob which then does an exact comparison.
This commit is contained in:
parent
dc46267833
commit
f29570138f
|
@ -56,8 +56,12 @@ RowId getValidPeerRow(RawDatabase& db, const ChatId& chatId)
|
|||
{
|
||||
bool validPeerExists{false};
|
||||
RowId validPeerRow;
|
||||
db.execNow(RawDatabase::Query(QStringLiteral("SELECT id FROM peers WHERE public_key='%1';")
|
||||
.arg(chatId.toString()),
|
||||
db.execNow(RawDatabase::Query(QStringLiteral("SELECT id FROM peers WHERE CAST(public_key AS BLOB)=?;"),
|
||||
// Note: The conversion to string then back to binary is intentional to
|
||||
// ensure we're using the binary presentation of the upper case ASCII
|
||||
// representation of the binary key, since we want to find the uppercase
|
||||
// entry or insert it ourselves. This is needed for the dbTo11 upgrade.
|
||||
{chatId.toString().toUtf8()},
|
||||
[&](const QVector<QVariant>& row) {
|
||||
validPeerRow = RowId{row[0].toLongLong()};
|
||||
validPeerExists = true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user