summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-04-11 17:55:18 -0300
committerQt by Nokia <qt-info@nokia.com>2012-04-12 23:01:37 +0200
commit4d79312f1c3ba04130129d7047aade56cee6c70f (patch)
tree918daba527c60887939d3da66478dcb458675ec0 /src
parent5aa8e5a81cfa1b7a45f5b1642d4706962ee821ed (diff)
Ensure proper handling of empty-but-present URL components
The new QUrl is able to distinguish a URL component that is empty from one that is absent. The previous one already had that capability for the port, fragment and query, and the new one extends that to the username, password and path. The path did not need this handling because its delimiter from the authority it part of the path. For example, a URL with no username is one where it's set to QString() (null). A URL like "http://:kde@kde.org" is understood as an empty-but-present username, for which toString(RemovePassword) will return "http://@kde.org", keeping the empty-but-present username. Change-Id: I2d97a7656f3f1099e3cf400b199e68e4c480d924 Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qurl.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 1cf7e30eb1..fbc8d761c2 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -480,7 +480,9 @@ inline void QUrlPrivate::appendAuthority(QString &appendTo, QUrl::FormattingOpti
{
if ((options & QUrl::RemoveUserInfo) != QUrl::RemoveUserInfo) {
appendUserInfo(appendTo, options, appendingTo);
- if (hasUserInfo())
+
+ // add '@' only if we added anything
+ if (hasUserName() || (hasPassword() && (options & QUrl::RemovePassword) == 0))
appendTo += QLatin1Char('@');
}
appendHost(appendTo, options);