Explicitly encode QStrings to utf8

This commit is contained in:
Dale Glass 2021-11-28 22:24:59 +01:00
parent 4394c2e00b
commit 0c453e7e0e
5 changed files with 32 additions and 32 deletions

View file

@ -182,7 +182,7 @@ void runTimingTests() {
const int EXTRA_JUNK_SIZE = 200; const int EXTRA_JUNK_SIZE = 200;
extraJunk.append((unsigned char)255); extraJunk.append((unsigned char)255);
for (int i = 0; i < EXTRA_JUNK_SIZE; i++) { for (int i = 0; i < EXTRA_JUNK_SIZE; i++) {
extraJunk.append(QString("junk")); extraJunk.append(QString("junk").toUtf8());
} }
{ {
@ -266,7 +266,7 @@ void runUnitTests() {
QByteArray codedValueBuffer = codedValue; QByteArray codedValueBuffer = codedValue;
codedValueBuffer.append((unsigned char)255); codedValueBuffer.append((unsigned char)255);
codedValueBuffer.append(QString("junk")); codedValueBuffer.append(QString("junk").toUtf8());
qDebug() << "codedValueBuffer:"; qDebug() << "codedValueBuffer:";
outputBufferBits((const unsigned char*)codedValueBuffer.constData(), codedValueBuffer.size()); outputBufferBits((const unsigned char*)codedValueBuffer.constData(), codedValueBuffer.size());

View file

@ -525,7 +525,7 @@ bool Wallet::readSecurityImage(const QString& inputFilePath, unsigned char** out
} else { } else {
foundFooter = (line == IMAGE_FOOTER); foundFooter = (line == IMAGE_FOOTER);
if (!foundFooter) { if (!foundFooter) {
base64EncryptedBuffer.append(line); base64EncryptedBuffer.append(line.toUtf8());
} }
} }
} }

View file

@ -569,7 +569,7 @@ void AccountManager::requestAccessToken(const QString& login, const QString& pas
postData.append("grant_type=password&"); postData.append("grant_type=password&");
postData.append("username=" + QUrl::toPercentEncoding(login) + "&"); postData.append("username=" + QUrl::toPercentEncoding(login) + "&");
postData.append("password=" + QUrl::toPercentEncoding(password) + "&"); postData.append("password=" + QUrl::toPercentEncoding(password) + "&");
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE); postData.append(QString("scope=%1").arg(ACCOUNT_MANAGER_REQUESTED_SCOPE).toUtf8());
request.setUrl(grantURL); request.setUrl(grantURL);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@ -590,10 +590,10 @@ void AccountManager::requestAccessTokenWithAuthCode(const QString& authCode, con
QByteArray postData; QByteArray postData;
postData.append("grant_type=authorization_code&"); postData.append("grant_type=authorization_code&");
postData.append("client_id=" + clientId + "&"); postData.append(QString("client_id=%1&").arg(clientId).toUtf8());
postData.append("client_secret=" + clientSecret + "&"); postData.append(QString("client_secret=%1&").arg(clientSecret).toUtf8());
postData.append("code=" + authCode + "&"); postData.append(QString("code=%1&").arg(authCode).toUtf8());
postData.append("redirect_uri=" + QUrl::toPercentEncoding(redirectUri)); postData.append(QByteArray("redirect_uri=") + QUrl::toPercentEncoding(redirectUri));
request.setUrl(grantURL); request.setUrl(grantURL);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@ -613,8 +613,8 @@ void AccountManager::requestAccessTokenWithSteam(QByteArray authSessionTicket) {
QByteArray postData; QByteArray postData;
postData.append("grant_type=password&"); postData.append("grant_type=password&");
postData.append("steam_auth_ticket=" + QUrl::toPercentEncoding(authSessionTicket) + "&"); postData.append(QByteArray("steam_auth_ticket=") + QUrl::toPercentEncoding(authSessionTicket) + "&");
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE); postData.append(QString("scope=%1").arg(ACCOUNT_MANAGER_REQUESTED_SCOPE).toUtf8());
request.setUrl(grantURL); request.setUrl(grantURL);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@ -635,9 +635,9 @@ void AccountManager::requestAccessTokenWithOculus(const QString& nonce, const QS
QByteArray postData; QByteArray postData;
postData.append("grant_type=password&"); postData.append("grant_type=password&");
postData.append("oculus_nonce=" + nonce + "&"); postData.append(QString("oculus_nonce=%1&").arg(nonce).toUtf8());
postData.append("oculus_id=" + oculusID + "&"); postData.append(QString("oculus_id=%1&").arg(oculusID).toUtf8());
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE); postData.append(QString("scope=%1").arg(ACCOUNT_MANAGER_REQUESTED_SCOPE).toUtf8());
request.setUrl(grantURL); request.setUrl(grantURL);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@ -666,8 +666,8 @@ void AccountManager::refreshAccessToken() {
QByteArray postData; QByteArray postData;
postData.append("grant_type=refresh_token&"); postData.append("grant_type=refresh_token&");
postData.append("refresh_token=" + QUrl::toPercentEncoding(_accountInfo.getAccessToken().refreshToken) + "&"); postData.append(QByteArray("refresh_token=") + QUrl::toPercentEncoding(_accountInfo.getAccessToken().refreshToken) + "&");
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE); postData.append(QString("scope=%1").arg(ACCOUNT_MANAGER_REQUESTED_SCOPE).toUtf8());
request.setUrl(grantURL); request.setUrl(grantURL);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

View file

@ -90,9 +90,9 @@ void DomainAccountManager::requestAccessToken(const QString& username, const QSt
// - Ignores "state" parameter. // - Ignores "state" parameter.
QByteArray formData; QByteArray formData;
formData.append("grant_type=password&"); formData.append("grant_type=password&");
formData.append("username=" + QUrl::toPercentEncoding(username) + "&"); formData.append(QByteArray("username=") + QUrl::toPercentEncoding(username) + "&");
formData.append("password=" + QUrl::toPercentEncoding(password) + "&"); formData.append(QByteArray("password=") + QUrl::toPercentEncoding(password) + "&");
formData.append("client_id=" + _currentAuth.clientID); formData.append(QString("client_id=%1").arg(_currentAuth.clientID).toUtf8());
request.setUrl(_currentAuth.authURL); request.setUrl(_currentAuth.authURL);

View file

@ -52,7 +52,7 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall
// Adding the action name // Adding the action name
QHttpPart actionPart; QHttpPart actionPart;
actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\""); actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\"");
actionPart.setBody(QByteArray().append(action)); actionPart.setBody(QByteArray().append(action.toUtf8()));
multipart->append(actionPart); multipart->append(actionPart);
// Log the local-time that this event was logged // Log the local-time that this event was logged