diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-03 09:51:50 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-09-03 09:54:29 (GMT) |
commit | 884f15e533eea8426e71af8ac61e7233357b103c (patch) | |
tree | 5f4dbd7ed864aa17b717d8cf7d89d80b8e1750f8 | |
parent | 82ff6626eaabbaed83f3cdfc429a2d011701ba03 (diff) | |
download | Qt-884f15e533eea8426e71af8ac61e7233357b103c.zip Qt-884f15e533eea8426e71af8ac61e7233357b103c.tar.gz Qt-884f15e533eea8426e71af8ac61e7233357b103c.tar.bz2 |
Accept empty authority segments in QUrl as different from not-present
See the task for discussion on why this is necessary and why it is
correct from the point of view of the RFC defining URIs.
Task-number: QTBUG-8701
Patch-by: Marja Hassinen
Signed-Off-By: Thiago Macieira
-rw-r--r-- | src/corelib/io/qurl.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qurl/tst_qurl.cpp | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 79a8ce4..f57a402 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5610,7 +5610,7 @@ QString QUrl::toString(FormattingOptions options) const if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority) { bool doFileScheme = d->scheme == QLatin1String("file") && ourPath.startsWith(QLatin1Char('/')); QString tmp = d->authority(options); - if (!tmp.isEmpty() || doFileScheme) { + if (!tmp.isNull() || doFileScheme) { if (doFileScheme && !ourPath.startsWith(QLatin1Char('/'))) url += QLatin1Char('/'); url += QLatin1String("//"); diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 820e32d..370bd13 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -194,6 +194,7 @@ private slots: void task_199967(); void task_240612(); void taskQTBUG_6962(); + void taskQTBUG_8701(); #ifdef QT3_SUPPORT void dirPath(); @@ -3912,5 +3913,17 @@ void tst_QUrl::taskQTBUG_6962() QCOMPARE(url.authority(), QString()); } +void tst_QUrl::taskQTBUG_8701() +{ + //bug 8701: foo:///bar mangled to foo:/bar + QString foo_triple_bar("foo:///bar"), foo_uni_bar("foo:/bar"); + + QCOMPARE(foo_triple_bar, QUrl(foo_triple_bar).toString()); + QCOMPARE(foo_uni_bar, QUrl(foo_uni_bar).toString()); + + QCOMPARE(foo_triple_bar, QUrl(foo_triple_bar, QUrl::StrictMode).toString()); // fails + QCOMPARE(foo_uni_bar, QUrl(foo_uni_bar, QUrl::StrictMode).toString()); +} + QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" |