summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qurl/tst_qurl.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-05-21 20:21:16 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-22 20:56:38 +0200
commit1ca791faf5b89c35b4b39d443d2118a882c3946b (patch)
treee11be9b68338786b61d12323f58e998211f89121 /tests/auto/corelib/io/qurl/tst_qurl.cpp
parent53d0624403f7f2ac8fe8364a7c5cd136717d40ed (diff)
Add the QUrl::FullyDecoded flag to the component formatting
This allows the QUrl component getters to return fully decoded data, like they did in Qt 4. This is necessary for some use-cases where the component like the user name, password or path are used outside the context of a URL. In those contexts, the percent-encoded data makes no sense, and the loss of data of what could be represented in a URL is acceptable. Also take the opportunity to expand the documentation of those getter methods, explaining what the options argument does. Discussed-on: http://lists.qt-project.org/pipermail/development/2012-May/003811.html Change-Id: I89f743cde78c02f169c88314bff0768714341419 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'tests/auto/corelib/io/qurl/tst_qurl.cpp')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 76e5c580a8..29b88980ad 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -3059,6 +3059,26 @@ void tst_QUrl::setComponents_data()
QTest::newRow("fragment-encode") << QUrl("http://example.com/foo#z")
<< int(Fragment) << "bar%23" << Decoded << true
<< PrettyDecoded << "bar%2523" << "http://example.com/foo#bar%2523";
+ // force decoding; note how the userinfo becomes ambiguous
+ QTest::newRow("userinfo-decode") << QUrl("http://example.com")
+ << int(UserInfo) << "hello%3Aworld:}}>b9o%25kR(" << Tolerant << true
+ << FullyDecoded << "hello:world:}}>b9o%kR("
+ << "http://hello%3Aworld:%7D%7D%3Eb9o%25kR(@example.com";
+ QTest::newRow("username-decode") << QUrl("http://example.com")
+ << int(UserName) << "hello%3Aworld%25" << Tolerant << true
+ << FullyDecoded << "hello:world%" << "http://hello%3Aworld%25@example.com";
+ QTest::newRow("password-decode") << QUrl("http://example.com")
+ << int(Password) << "}}>b9o%25kR(" << Tolerant << true
+ << FullyDecoded << "}}>b9o%kR(" << "http://:%7D%7D%3Eb9o%25kR(@example.com";
+ QTest::newRow("path-decode") << QUrl("http://example.com/")
+ << int(Path) << "/bar%25foo" << Tolerant << true
+ << FullyDecoded << "/bar%foo" << "http://example.com/bar%25foo";
+ QTest::newRow("query-decode") << QUrl("http://example.com/foo?qq")
+ << int(Query) << "bar%25foo" << Tolerant << true
+ << FullyDecoded << "bar%foo" << "http://example.com/foo?bar%25foo";
+ QTest::newRow("fragment-decode") << QUrl("http://example.com/foo#qq")
+ << int(Fragment) << "bar%25foo" << Tolerant << true
+ << FullyDecoded << "bar%foo" << "http://example.com/foo#bar%25foo";
}
void tst_QUrl::setComponents()