diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-03-30 16:21:45 -0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-11 23:32:18 +0200 |
commit | 997ac954abe8e4f7d9323f13a79989f277de8301 (patch) | |
tree | bcbeefb06a533d68d59e38bb68a63d7f7f915f15 /tests/auto/corelib | |
parent | a01c662d3737fd9f26a7e4455d7bcb03628155d7 (diff) |
Allow {} to remain decoded in URLs in the path and query
This allows things like http://example.com/{1234-5678}?id={abcd-ef01}.
But do not allow it in other parts of the URL. I could allow it in the
fragment, but in the username and password it would be too ugly.
In order to do that, make DecodeReserved use two bits and have
PrettyDecoded set only one of them. That way, toString(PrettyDecoded)
can be distinguished from toString(PrettyDecoded | DecodeReserved),
just as path(PrettyDecoded) can be distinguished from
path(PrettyDecoded & ~DecodeDelimiters).
Also, take the opportunity to avoid decoding the reserved characters
in the query. Keep them encoded as they should be.
Change-Id: I1604a0c8015c6b03dc2fbf49ea9d1dbed96fc186
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/io/qurl/tst_qurl.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 7deb0fc381..f8a0edf0dc 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -2765,6 +2765,16 @@ void tst_QUrl::componentEncodings_data() << "host" << "%5B%3A%40/%5D:%5B:%40/%5D@host" << "/:@[?#]" << "[?%3F#]%5B:%3A@%40%5D" << "#" << "x://%5B%3A%40%2F%5D:%5B:%40%2F%5D@host/:@[%3F%23]?[?%3F%23]%5B:%3A@%40%5D##"; + + // the pretty form keeps the other characters decoded everywhere + // except when rebuilding the full URL, when we only allow "{}" to remain decoded + QTest::newRow("pretty-reserved") << QUrl("x://\"<>^\\{|}:\"<>^\\{|}@host/\"<>^\\{|}?\"<>^\\{|}#\"<>^\\{|}") + << int(QUrl::PrettyDecoded) + << "\"<>^\\{|}" << "\"<>^\\{|}" << "\"<>^\\{|}:\"<>^\\{|}" + << "host" << "\"<>^\\{|}:\"<>^\\{|}@host" + << "/\"<>^\\{|}" << "\"<>^\\{|}" << "\"<>^\\{|}" + << "x://%22%3C%3E%5E%5C%7B%7C%7D:%22%3C%3E%5E%5C%7B%7C%7D@host/%22%3C%3E%5E%5C{%7C}" + "?%22%3C%3E%5E%5C{%7C}#%22%3C%3E%5E%5C%7B%7C%7D"; } void tst_QUrl::componentEncodings() |