mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-03 02:14:16 +00:00
parent
46c1c9de65
commit
529e49aea7
@ -208,7 +208,7 @@ bool RequestParser::parseRequestLine(const QString &line)
|
|||||||
const int sepPos = url.indexOf('?');
|
const int sepPos = url.indexOf('?');
|
||||||
const QByteArrayView pathComponent = ((sepPos == -1) ? url : QByteArrayView(url).mid(0, sepPos));
|
const QByteArrayView pathComponent = ((sepPos == -1) ? url : QByteArrayView(url).mid(0, sepPos));
|
||||||
|
|
||||||
m_request.path = QString::fromUtf8(QByteArray::fromPercentEncoding(pathComponent.toByteArray()));
|
m_request.path = QString::fromUtf8(QByteArray::fromPercentEncoding(asQByteArray(pathComponent)));
|
||||||
|
|
||||||
if (sepPos >= 0)
|
if (sepPos >= 0)
|
||||||
{
|
{
|
||||||
@ -223,10 +223,11 @@ bool RequestParser::parseRequestLine(const QString &line)
|
|||||||
|
|
||||||
const QByteArrayView nameComponent = param.mid(0, eqCharPos);
|
const QByteArrayView nameComponent = param.mid(0, eqCharPos);
|
||||||
const QByteArrayView valueComponent = param.mid(eqCharPos + 1);
|
const QByteArrayView valueComponent = param.mid(eqCharPos + 1);
|
||||||
const QString paramName = QString::fromUtf8(QByteArray::fromPercentEncoding(nameComponent.toByteArray()).replace('+', ' '));
|
const QString paramName = QString::fromUtf8(
|
||||||
|
QByteArray::fromPercentEncoding(asQByteArray(nameComponent)).replace('+', ' '));
|
||||||
const QByteArray paramValue = valueComponent.isNull()
|
const QByteArray paramValue = valueComponent.isNull()
|
||||||
? QByteArray("")
|
? QByteArray("")
|
||||||
: QByteArray::fromPercentEncoding(valueComponent.toByteArray()).replace('+', ' ');
|
: QByteArray::fromPercentEncoding(asQByteArray(valueComponent)).replace('+', ' ');
|
||||||
|
|
||||||
m_request.query[paramName] = paramValue;
|
m_request.query[paramName] = paramValue;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,13 @@ QList<QByteArrayView> Utils::ByteArray::splitToViews(const QByteArrayView in, co
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray Utils::ByteArray::asQByteArray(const QByteArrayView view)
|
||||||
|
{
|
||||||
|
// `QByteArrayView::toByteArray()` will deep copy the data
|
||||||
|
// So we provide our own fast path for appropriate situations/code
|
||||||
|
return QByteArray::fromRawData(view.constData(), view.size());
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray Utils::ByteArray::toBase32(const QByteArray &in)
|
QByteArray Utils::ByteArray::toBase32(const QByteArray &in)
|
||||||
{
|
{
|
||||||
const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
const char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||||
|
@ -39,6 +39,7 @@ namespace Utils::ByteArray
|
|||||||
{
|
{
|
||||||
// Mimic QStringView(in).split(sep, behavior)
|
// Mimic QStringView(in).split(sep, behavior)
|
||||||
QList<QByteArrayView> splitToViews(QByteArrayView in, QByteArrayView sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts);
|
QList<QByteArrayView> splitToViews(QByteArrayView in, QByteArrayView sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts);
|
||||||
|
QByteArray asQByteArray(QByteArrayView view);
|
||||||
|
|
||||||
QByteArray toBase32(const QByteArray &in);
|
QByteArray toBase32(const QByteArray &in);
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,8 @@ bool Utils::Password::PBKDF2::verify(const QByteArray &secret, const QByteArray
|
|||||||
if (list.size() != 2)
|
if (list.size() != 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QByteArray salt = QByteArray::fromBase64(list[0].toByteArray());
|
const QByteArray salt = QByteArray::fromBase64(Utils::ByteArray::asQByteArray(list[0]));
|
||||||
const QByteArray key = QByteArray::fromBase64(list[1].toByteArray());
|
const QByteArray key = QByteArray::fromBase64(Utils::ByteArray::asQByteArray(list[1]));
|
||||||
|
|
||||||
std::array<unsigned char, 64> outBuf {};
|
std::array<unsigned char, 64> outBuf {};
|
||||||
const int hmacResult = PKCS5_PBKDF2_HMAC(password.constData(), password.size()
|
const int hmacResult = PKCS5_PBKDF2_HMAC(password.constData(), password.size()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user