Merge pull request #1485 from daleglass/qt5-fix-qbytearray-append

Housekeeping: Explicitly encode QStrings to utf8.
This commit is contained in:
Kalila 2022-01-20 17:04:54 -05:00 committed by GitHub
commit e2332bae29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 29 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("scope=" + 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,9 +590,9 @@ 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("client_id=" + clientId.toUtf8() + "&");
postData.append("client_secret=" + clientSecret + "&"); postData.append("client_secret=" + clientSecret.toUtf8() + "&");
postData.append("code=" + authCode + "&"); postData.append("code=" + authCode.toUtf8() + "&");
postData.append("redirect_uri=" + QUrl::toPercentEncoding(redirectUri)); postData.append("redirect_uri=" + QUrl::toPercentEncoding(redirectUri));
request.setUrl(grantURL); request.setUrl(grantURL);
@ -614,7 +614,7 @@ 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("steam_auth_ticket=" + QUrl::toPercentEncoding(authSessionTicket) + "&");
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE); postData.append("scope=" + 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("oculus_nonce=" + nonce.toUtf8() + "&");
postData.append("oculus_id=" + oculusID + "&"); postData.append("oculus_id=" + oculusID.toUtf8() + "&");
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE); postData.append("scope=" + 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");
@ -667,7 +667,7 @@ 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("refresh_token=" + QUrl::toPercentEncoding(_accountInfo.getAccessToken().refreshToken) + "&");
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE); postData.append("scope=" + 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

@ -92,7 +92,7 @@ void DomainAccountManager::requestAccessToken(const QString& username, const QSt
formData.append("grant_type=password&"); formData.append("grant_type=password&");
formData.append("username=" + QUrl::toPercentEncoding(username) + "&"); formData.append("username=" + QUrl::toPercentEncoding(username) + "&");
formData.append("password=" + QUrl::toPercentEncoding(password) + "&"); formData.append("password=" + QUrl::toPercentEncoding(password) + "&");
formData.append("client_id=" + _currentAuth.clientID); formData.append("client_id=" + _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

View file

@ -63,11 +63,11 @@ bool OctreeUtils::RawOctreeData::readOctreeDataInfoFromFile(QString path) {
QByteArray OctreeUtils::RawOctreeData::toByteArray() { QByteArray OctreeUtils::RawOctreeData::toByteArray() {
QByteArray jsonString; QByteArray jsonString;
jsonString += QString("{\n \"DataVersion\": %1,\n").arg(dataVersion); jsonString += QString("{\n \"DataVersion\": %1,\n").arg(dataVersion).toUtf8();
writeSubclassData(jsonString); writeSubclassData(jsonString);
jsonString += QString(",\n \"Id\": \"%1\",\n \"Version\": %2\n}").arg(id.toString()).arg(version); jsonString += QString(",\n \"Id\": \"%1\",\n \"Version\": %2\n}").arg(id.toString()).arg(version).toUtf8();
return jsonString; return jsonString;
} }