-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
76f45e6
commit eb54646
Showing
3 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,8 @@ private slots: | |
void toString_PreferLocalFile(); | ||
void toString_constructed_data(); | ||
void toString_constructed(); | ||
void toDisplayString_PreferLocalFile_data(); | ||
void toDisplayString_PreferLocalFile(); | ||
void toAndFromStringList_data(); | ||
void toAndFromStringList(); | ||
void isParentOf_data(); | ||
|
@@ -1207,6 +1209,32 @@ void tst_QUrl::toString_constructed() | |
QCOMPARE(url.toEncoded(formattingOptions), asEncoded); | ||
} | ||
|
||
void tst_QUrl::toDisplayString_PreferLocalFile_data() | ||
{ | ||
QTest::addColumn<QUrl>("url"); | ||
QTest::addColumn<QString>("string"); | ||
|
||
QTest::newRow("basic") << QUrl::fromLocalFile("/home/charles/foomoo") | ||
<< QString::fromLatin1("/home/charles/foomoo"); | ||
QTest::newRow("with%") << QUrl::fromLocalFile("/home/charles/foo%20moo") | ||
<< QString::fromLatin1("/home/charles/foo%20moo"); | ||
QTest::newRow("non-local") << QUrl("file://host/foo") | ||
<< QString::fromLatin1("//host/foo"); | ||
QTest::newRow("query-and-fragment") << QUrl("file://user:[email protected]/a?b=c%20d%23e#frag%23ment") | ||
<< QString::fromLatin1("file://[email protected]/a?b=c d%23e#frag%23ment"); | ||
QTest::newRow("http") << QUrl("http://user:[email protected]/a?b=c%20d%23e#frag%23ment") | ||
<< QString::fromLatin1("http://[email protected]/a?b=c d%23e#frag%23ment"); | ||
} | ||
|
||
void tst_QUrl::toDisplayString_PreferLocalFile() | ||
{ | ||
QFETCH(QUrl, url); | ||
QFETCH(QString, string); | ||
|
||
if (url.isLocalFile() && url.query().isEmpty() && url.fragment().isEmpty()) | ||
QCOMPARE(url.toLocalFile(), string); | ||
QCOMPARE(url.toDisplayString(QUrl::PreferLocalFile), string); | ||
} | ||
|
||
void tst_QUrl::isParentOf() | ||
{ | ||
|