diff options
author | David Faure <david.faure@kdab.com> | 2013-07-25 12:52:27 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-21 23:50:44 +0200 |
commit | 1de1470189991f5334439048a4d875e97193a82d (patch) | |
tree | 92820928624215e52b6b1745de2b3669885b4d56 /src/corelib | |
parent | f874a5dd8b42a346ee7d036c4de78a9da26f961d (diff) |
QUrl: Use decoded mode by default for individual getters/setters.
This fixes the wrong value for path() and fileName() when a
path or file name actually contains a '%'.
userInfo() and authority() are not individual getters, they combine
two or more fields, so full decoding isn't possible (e.g. username
containing a ':').
[ChangeLog][Important Behavior Changes][QUrl and QUrlQuery]QUrl now
defaults to decoded mode in the getters and setters for userName,
password, host, topLevelDomain, path and fileName. This means a '%'
in one of those fields is now returned (or set) as '%' rather than "%25".
In the unlikely case where the former behavior was expected, pass PrettyDecoded
to the getter and TolerantMode to the setter.
Change-Id: Iaeecbde9c269882e79f08b29ff8c661157c41743
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qurl.cpp | 8 | ||||
-rw-r--r-- | src/corelib/io/qurl.h | 20 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index f33e446a98..9f9653ea94 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3252,8 +3252,8 @@ QUrl QUrl::adjusted(QUrl::FormattingOptions options) const that.setPath(QString()); } else if (options & (StripTrailingSlash | RemoveFilename | NormalizePathSegments)) { QString path; - d->appendPath(path, options, QUrlPrivate::Path); - that.setPath(path); + d->appendPath(path, options | FullyEncoded, QUrlPrivate::Path); + that.setPath(path, TolerantMode); } return that; } @@ -3967,9 +3967,9 @@ uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW static QUrl adjustFtpPath(QUrl url) { if (url.scheme() == ftpScheme()) { - QString path = url.path(); + QString path = url.path(QUrl::PrettyDecoded); if (path.startsWith(QLatin1String("//"))) - url.setPath(QLatin1String("/%2F") + path.midRef(2)); + url.setPath(QLatin1String("/%2F") + path.midRef(2), QUrl::TolerantMode); } return url; } diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 457440bb89..abb7df0056 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -209,22 +209,22 @@ public: void setUserInfo(const QString &userInfo, ParsingMode mode = TolerantMode); QString userInfo(ComponentFormattingOptions options = PrettyDecoded) const; - void setUserName(const QString &userName, ParsingMode mode = TolerantMode); - QString userName(ComponentFormattingOptions options = PrettyDecoded) const; + void setUserName(const QString &userName, ParsingMode mode = DecodedMode); + QString userName(ComponentFormattingOptions options = FullyDecoded) const; - void setPassword(const QString &password, ParsingMode mode = TolerantMode); - QString password(ComponentFormattingOptions = PrettyDecoded) const; + void setPassword(const QString &password, ParsingMode mode = DecodedMode); + QString password(ComponentFormattingOptions = FullyDecoded) const; - void setHost(const QString &host, ParsingMode mode = TolerantMode); - QString host(ComponentFormattingOptions = PrettyDecoded) const; - QString topLevelDomain(ComponentFormattingOptions options = PrettyDecoded) const; + void setHost(const QString &host, ParsingMode mode = DecodedMode); + QString host(ComponentFormattingOptions = FullyDecoded) const; + QString topLevelDomain(ComponentFormattingOptions options = FullyDecoded) const; void setPort(int port); int port(int defaultPort = -1) const; - void setPath(const QString &path, ParsingMode mode = TolerantMode); - QString path(ComponentFormattingOptions options = PrettyDecoded) const; - QString fileName(ComponentFormattingOptions options = PrettyDecoded) const; + void setPath(const QString &path, ParsingMode mode = DecodedMode); + QString path(ComponentFormattingOptions options = FullyDecoded) const; + QString fileName(ComponentFormattingOptions options = FullyDecoded) const; bool hasQuery() const; void setQuery(const QString &query, ParsingMode mode = TolerantMode); |