HTTP authentication fails if QUrl contains password with %

Default for QUrl::password() and QUrl::userName() is in Qt 5.1 QUrl::PrettyDecoded
which means the return value may contain percent-encodings. For authentication
we need the real decoded result, and should instead use QUrl::FullyDecoded.

Note this bug has already been fixed indirectly in Qt 5.2 since the default for the
two methods was changed to QUrl::FullyDecoded.

Change-Id: Ia0f38c073cb001e37ad8b3eda40b3db756bec3dc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Allan Sandfeld Jensen 2013-09-16 19:00:40 +02:00 committed by The Qt Project
parent 3ec52de5e9
commit 1178804997
2 changed files with 4 additions and 4 deletions

View File

@ -222,8 +222,8 @@ bool QHttpNetworkConnectionChannel::sendRequest()
QAuthenticator &auth = authenticator;
if (url.userName() != auth.user()
|| (!url.password().isEmpty() && url.password() != auth.password())) {
auth.setUser(url.userName());
auth.setPassword(url.password());
auth.setUser(url.userName(QUrl::FullyDecoded));
auth.setPassword(url.password(QUrl::FullyDecoded));
connection->d_func()->copyCredentials(connection->d_func()->indexOf(socket), &auth, false);
}
// clear the userinfo, since we use the same request for resending

View File

@ -1229,8 +1229,8 @@ void QNetworkAccessManagerPrivate::authenticationRequired(QAuthenticator *authen
// if credentials are included in the url, then use them
if (!url.userName().isEmpty()
&& !url.password().isEmpty()) {
authenticator->setUser(url.userName());
authenticator->setPassword(url.password());
authenticator->setUser(url.userName(QUrl::FullyDecoded));
authenticator->setPassword(url.password(QUrl::FullyDecoded));
*urlForLastAuthentication = url;
authenticationManager->cacheCredentials(url, authenticator);
return;