summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2013-09-16 19:00:40 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-17 03:11:36 +0200
commit117880499754b14bbada9646b85feef066d7b959 (patch)
tree18ebebf3e706a18a5d564f9e5869c09792162fba
parent3ec52de5e96c332a207b48c8a7655d3fdfc5edb8 (diff)
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>
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp4
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index e14f426583..56984d144e 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -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
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 10d19bb7aa..b86efb21a8 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -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;