summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurl.cpp
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2020-06-26 11:06:49 +0200
committerDavid Faure <david.faure@kdab.com>2020-06-29 16:45:31 +0200
commiteb546469849d2bf560f41b14366832e1f8b22456 (patch)
treed857134211ab98514df344ff3beb98e1c13645f6 /src/corelib/io/qurl.cpp
parent76f45e6e972f6fdf26102a685ab9205c04ee9172 (diff)
Fix QUrl::toDisplayString(PreferLocalFile) returning an encoded path
It's supposed to return the same as toLocalFile(), for local files, which means passing QUrl::FullyDecoded just like QUrl::toLocalFile() does. But a few code paths were testing component formatting options without masking other FormattingOptions like RemovePassword, so this had to be fixed. Fixes: QTBUG-84594 Change-Id: I82f15148b6d93516200f9ad6258d474e7f10924a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r--src/corelib/io/qurl.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index db70fa86be..1a266702eb 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -836,7 +836,8 @@ recodeFromUser(const QString &input, const ushort *actions, int from, int to)
static inline void appendToUser(QString &appendTo, QStringView value, QUrl::FormattingOptions options,
const ushort *actions)
{
- if (options == QUrl::PrettyDecoded) {
+ // Test ComponentFormattingOptions, ignore FormattingOptions.
+ if ((options & 0xFFFF0000) == QUrl::PrettyDecoded) {
appendTo += value;
return;
}
@@ -3276,9 +3277,10 @@ QString QUrl::toString(FormattingOptions options) const
// also catches isEmpty()
return url;
}
- if (options == QUrl::FullyDecoded) {
+ if ((options & QUrl::FullyDecoded) == QUrl::FullyDecoded) {
qWarning("QUrl: QUrl::FullyDecoded is not permitted when reconstructing the full URL");
- options = QUrl::PrettyDecoded;
+ options &= ~QUrl::FullyDecoded;
+ //options |= QUrl::PrettyDecoded; // no-op, value is 0
}
// return just the path if:
@@ -3291,7 +3293,7 @@ QString QUrl::toString(FormattingOptions options) const
&& (!d->hasQuery() || options.testFlag(QUrl::RemoveQuery))
&& (!d->hasFragment() || options.testFlag(QUrl::RemoveFragment))
&& isLocalFile()) {
- url = d->toLocalFile(options);
+ url = d->toLocalFile(options | QUrl::FullyDecoded);
return url;
}