mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 11:38:50 -07:00
Make use of std algorithms
This commit is contained in:
parent
40eb8a1f4a
commit
6d29a3af60
10 changed files with 67 additions and 61 deletions
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "requestparser.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringList>
|
||||
|
@ -242,12 +244,10 @@ bool RequestParser::parsePostMessage(const QByteArray &data)
|
|||
const QByteArray endDelimiter = QByteArray("--") + delimiter + QByteArray("--") + CRLF;
|
||||
multipart.push_back(viewWithoutEndingWith(multipart.takeLast(), endDelimiter));
|
||||
|
||||
for (const auto &part : multipart) {
|
||||
if (!parseFormData(part))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return std::all_of(multipart.cbegin(), multipart.cend(), [this](const QByteArray &part)
|
||||
{
|
||||
return this->parseFormData(part);
|
||||
});
|
||||
}
|
||||
|
||||
qWarning() << Q_FUNC_INFO << "unknown content type:" << contentType;
|
||||
|
|
|
@ -50,22 +50,16 @@ namespace
|
|||
|
||||
QList<QSslCipher> safeCipherList()
|
||||
{
|
||||
const QStringList badCiphers = {"idea", "rc4"};
|
||||
const QList<QSslCipher> allCiphers = QSslSocket::supportedCiphers();
|
||||
const QStringList badCiphers {"idea", "rc4"};
|
||||
const QList<QSslCipher> allCiphers {QSslSocket::supportedCiphers()};
|
||||
QList<QSslCipher> safeCiphers;
|
||||
for (const QSslCipher &cipher : allCiphers) {
|
||||
bool isSafe = true;
|
||||
for (const QString &badCipher : badCiphers) {
|
||||
if (cipher.name().contains(badCipher, Qt::CaseInsensitive)) {
|
||||
isSafe = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSafe)
|
||||
safeCiphers += cipher;
|
||||
}
|
||||
|
||||
std::copy_if(allCiphers.cbegin(), allCiphers.cend(), std::back_inserter(safeCiphers), [&badCiphers](const QSslCipher &cipher)
|
||||
{
|
||||
return std::none_of(badCiphers.cbegin(), badCiphers.cend(), [&cipher](const QString &badCipher)
|
||||
{
|
||||
return cipher.name().contains(badCipher, Qt::CaseInsensitive);
|
||||
});
|
||||
});
|
||||
return safeCiphers;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue