summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2013-09-08 15:16:26 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-11 01:26:07 +0200
commitaba336c2b4ad8926dc8a000718bbb7f8a6d5a72d (patch)
tree5ca738ded3609a8d5f39f1dac22e4c81023cccb8 /src/corelib
parent8fa0e4d1d202a3d1302469e6827c622423328383 (diff)
QUrl: ensure that setPath("//path") doesn't lead to scheme://path
which would interpret 'path' as a hostname. The check is in the public setPath so that the internal one can still support parsing URLs such as ftp://ftp.example.com//path. [ChangeLog][Important Behavior Changes][QUrl and QUrlQuery]QUrl now normalizes the path given in setPath, removing ./ and ../ and duplicate slashes. Change-Id: I05ccd8a1d813de45e460384239c059418a8e6a08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-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 9f9653ea94..1854ea9487 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -2386,6 +2386,7 @@ void QUrl::setPath(const QString &path, ParsingMode mode)
mode = TolerantMode;
}
+ data = qt_normalizePathSegments(data, false);
d->setPath(data, 0, data.length());
// optimized out, since there is no path delimiter
@@ -3251,9 +3252,10 @@ QUrl QUrl::adjusted(QUrl::FormattingOptions options) const
if (options & RemovePath) {
that.setPath(QString());
} else if (options & (StripTrailingSlash | RemoveFilename | NormalizePathSegments)) {
+ that.detach();
QString path;
d->appendPath(path, options | FullyEncoded, QUrlPrivate::Path);
- that.setPath(path, TolerantMode);
+ that.d->setPath(path, 0, path.length());
}
return that;
}