diff options
author | Jesus Fernandez <jesus.fernandez@qt.io> | 2017-03-28 18:50:11 +0200 |
---|---|---|
committer | Jesus Fernandez <Jesus.Fernandez@qt.io> | 2017-03-29 06:50:07 +0000 |
commit | decac344458ddd45ec8f03d721d40795c7095404 (patch) | |
tree | 8e696604aad1dfdb835c495a715db79fee228e33 | |
parent | 97db61d77432eefbc489d292cc95ed0a4902e77f (diff) |
Fix HTML response when using multibyte characters
Report correct Content-Length even when multibyte
characters are passed to the
QOAuthHttpServerReplyHandler::setCallbackText() function.
Previously the length of a QString was used, that would
be less than the length of the UTF-8 encoding of it that
was the actual content.
Task-number: QTBUG-59725
Change-Id: I1536b636027f81bb234969051a8fc9d88e506f8c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
-rw-r--r-- | src/oauth/qoauthhttpserverreplyhandler.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/oauth/qoauthhttpserverreplyhandler.cpp b/src/oauth/qoauthhttpserverreplyhandler.cpp index 2c0d336..3e3fdf6 100644 --- a/src/oauth/qoauthhttpserverreplyhandler.cpp +++ b/src/oauth/qoauthhttpserverreplyhandler.cpp @@ -118,11 +118,11 @@ void QOAuthHttpServerReplyHandlerPrivate::_q_answerClient(QTcpSocket *socket, co receivedData.insert(it->first, it->second); Q_EMIT q->callbackReceived(receivedData); - const QString html = QLatin1String("<html><head><title>") + - qApp->applicationName() + - QLatin1String("</title></head><body>") + - text + - QLatin1String("</body></html>"); + const QByteArray html = QByteArrayLiteral("<html><head><title>") + + qApp->applicationName().toUtf8() + + QByteArrayLiteral("</title></head><body>") + + text.toUtf8() + + QByteArrayLiteral("</body></html>"); const QByteArray htmlSize = QString::number(html.size()).toUtf8(); const QByteArray replyMessage = QByteArrayLiteral("HTTP/1.0 200 OK \r\n" @@ -130,7 +130,7 @@ void QOAuthHttpServerReplyHandlerPrivate::_q_answerClient(QTcpSocket *socket, co "charset=\"utf-8\"\r\n" "Content-Length: ") + htmlSize + QByteArrayLiteral("\r\n\r\n") + - html.toUtf8(); + html; socket->write(replyMessage); } |