summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-09-19 14:47:09 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-02 22:34:42 +0200
commitadce435a0c6f6d515fa4dd3af86c725843158514 (patch)
tree625a6e3389a9686708ba498ffb1af88c30babd36 /src
parent7d62f8ace542e04e3ddf92eec4fdad8d34ac9585 (diff)
Make QUrl::toString() / toEncoded() return empty for invalid URLs
Change-Id: I6ebb4ad2901a9bacb09fb81082202f37ebbc2e97 Reviewed-by: David Faure <faure@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qurl.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 9d1691010e..38eb613d74 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -2876,7 +2876,10 @@ QString QUrl::url(FormattingOptions options) const
*/
QString QUrl::toString(FormattingOptions options) const
{
- if (!d) return QString();
+ if (!isValid()) {
+ // also catches isEmpty()
+ return QString();
+ }
if (options == QUrl::FullyDecoded) {
qWarning("QUrl: QUrl::FullyDecoded is not permitted when reconstructing the full URL");
options = QUrl::PrettyDecoded;
@@ -2916,10 +2919,6 @@ QString QUrl::toString(FormattingOptions options) const
}
if (!(options & QUrl::RemovePath)) {
- // check if we need to insert a slash
- if (!pathIsAbsolute && !d->path.isEmpty() && !url.isEmpty() && !url.endsWith(QLatin1Char(':')))
- url += QLatin1Char('/');
-
d->appendPath(url, options, QUrlPrivate::FullUrl);
// check if we need to remove trailing slashes
if ((options & StripTrailingSlash) && !d->path.isEmpty() && d->path != QLatin1String("/") && url.endsWith(QLatin1Char('/')))