summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2009-12-28 16:56:14 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-12-28 16:56:14 (GMT)
commit8c306f8ee137baebc312a126c4e0d27bb9150f69 (patch)
tree6e4fb9f5013a1c9fd26afdfe843251261ac41337 /src/corelib
parentd0c3d9770b5c33810f12e409e2304957079a2608 (diff)
downloadQt-8c306f8ee137baebc312a126c4e0d27bb9150f69.zip
Qt-8c306f8ee137baebc312a126c4e0d27bb9150f69.tar.gz
Qt-8c306f8ee137baebc312a126c4e0d27bb9150f69.tar.bz2
QUrl::toEncoded() fix for the case of "password, but no username".
QUrl::setPassword() without QUrl::setUserName() is actually useful, e.g. for kde's ldap:// slave. QUrl::toString() already handled this correctly, but QUrl::toEncoded() would forget the password in such a case. Autotest added. Merge-request: 2276 Reviewed-by: Olivier Goffart <ogoffart@trolltech.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qurl.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index fd51bcf..6ac6468 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3864,14 +3864,18 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const
url += "//";
if ((options & QUrl::RemoveUserInfo) != QUrl::RemoveUserInfo) {
+ bool hasUserOrPass = false;
if (!userName.isEmpty()) {
url += encodedUserName;
- if (!(options & QUrl::RemovePassword) && !password.isEmpty()) {
- url += ':';
- url += encodedPassword;
- }
- url += '@';
+ hasUserOrPass = true;
}
+ if (!(options & QUrl::RemovePassword) && !password.isEmpty()) {
+ url += ':';
+ url += encodedPassword;
+ hasUserOrPass = true;
+ }
+ if (hasUserOrPass)
+ url += '@';
}
if (host.startsWith(QLatin1Char('['))) {