Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-01-18 16:56:17 +0300
committerMatthieu Gallien (Rebase PR Action) <matthieu_gallien@yahoo.fr>2021-08-11 20:13:44 +0300
commit3bc026a5579d04d129d334b4a0c425268ac1efc0 (patch)
treec2892c384329b11a0698ce72f7c0002dc7ae19f4 /src/common
parentf977a54694fbca67a3695cda01dbc0b35687dbc7 (diff)
Make findBestChecksum case insensitive
Especially the casing of ADLER32 did not match the server.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/checksums.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/common/checksums.cpp b/src/common/checksums.cpp
index 142c05ec5..bdf95b358 100644
--- a/src/common/checksums.cpp
+++ b/src/common/checksums.cpp
@@ -142,20 +142,21 @@ QByteArray makeChecksumHeader(const QByteArray &checksumType, const QByteArray &
return header;
}
-QByteArray findBestChecksum(const QByteArray &checksums)
+QByteArray findBestChecksum(const QByteArray &_checksums)
{
+ const auto checksums = QString::fromUtf8(_checksums);
int i = 0;
// The order of the searches here defines the preference ordering.
- if (-1 != (i = checksums.indexOf("SHA3-256:"))
- || -1 != (i = checksums.indexOf("SHA256:"))
- || -1 != (i = checksums.indexOf("SHA1:"))
- || -1 != (i = checksums.indexOf("MD5:"))
- || -1 != (i = checksums.indexOf("Adler32:"))) {
+ if (-1 != (i = checksums.indexOf(QLatin1String("SHA3-256:"), 0, Qt::CaseInsensitive))
+ || -1 != (i = checksums.indexOf(QLatin1String("SHA256:"), 0, Qt::CaseInsensitive))
+ || -1 != (i = checksums.indexOf(QLatin1String("SHA1:"), 0, Qt::CaseInsensitive))
+ || -1 != (i = checksums.indexOf(QLatin1String("MD5:"), 0, Qt::CaseInsensitive))
+ || -1 != (i = checksums.indexOf(QLatin1String("ADLER32:"), 0, Qt::CaseInsensitive))) {
// Now i is the start of the best checksum
// Grab it until the next space or end of string.
- auto checksum = checksums.mid(i);
- return checksum.mid(0, checksum.indexOf(" "));
+ return _checksums.mid(i, _checksums.indexOf(' ', i) - i);
}
+ qCWarning(lcChecksums) << "Failed to parse" << _checksums;
return QByteArray();
}