diff options
author | David Faure <david.faure@kdab.com> | 2020-06-26 11:06:49 +0200 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2020-07-02 19:13:33 +0200 |
commit | 6dd1ecb46d6e45b7a123ef519545ee94066be221 (patch) | |
tree | adafdf19ff9b5060bd676aec84719531667551ea /src/corelib/io | |
parent | 7872e48622b0bf1001d50994bc6e05a3b6d9ccfd (diff) | |
download | qtbase-6dd1ecb46d6e45b7a123ef519545ee94066be221.tar.gz |
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>
(cherry picked from commit eb546469849d2bf560f41b14366832e1f8b22456)
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qurl.cpp | 10 | ||||
-rw-r--r-- | src/corelib/io/qurlrecode.cpp | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 104161bc33..0c81af52d7 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -834,7 +834,8 @@ recodeFromUser(const QString &input, const ushort *actions, int from, int to) static inline void appendToUser(QString &appendTo, const QStringRef &value, QUrl::FormattingOptions options, const ushort *actions) { - if (options == QUrl::PrettyDecoded) { + // Test ComponentFormattingOptions, ignore FormattingOptions. + if ((options & 0xFFFF0000) == QUrl::PrettyDecoded) { appendTo += value; return; } @@ -3321,9 +3322,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: @@ -3336,7 +3338,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; } diff --git a/src/corelib/io/qurlrecode.cpp b/src/corelib/io/qurlrecode.cpp index 35ede8d078..3b2ef4a73d 100644 --- a/src/corelib/io/qurlrecode.cpp +++ b/src/corelib/io/qurlrecode.cpp @@ -672,7 +672,7 @@ qt_urlRecode(QString &appendTo, const QChar *begin, const QChar *end, QUrl::ComponentFormattingOptions encoding, const ushort *tableModifications) { uchar actionTable[sizeof defaultActionTable]; - if (encoding == QUrl::FullyDecoded) { + if ((encoding & QUrl::FullyDecoded) == QUrl::FullyDecoded) { return decode(appendTo, reinterpret_cast<const ushort *>(begin), reinterpret_cast<const ushort *>(end)); } |