summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp16
-rw-r--r--tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp28
-rw-r--r--tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp4
3 files changed, 26 insertions, 22 deletions
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 1f3dcae8b7..45f24710ff 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -1102,7 +1102,7 @@ void tst_QUrl::fromLocalFile()
QUrl url = QUrl::fromLocalFile(theFile);
- QCOMPARE(url.toString(QUrl::MostDecoded), theUrl);
+ QCOMPARE(url.toString(QUrl::DecodeReserved), theUrl);
QCOMPARE(url.path(), thePath);
}
@@ -2696,6 +2696,8 @@ void tst_QUrl::componentEncodings_data()
QTest::addColumn<QString>("fragment");
QTest::addColumn<QString>("toString");
+ const int MostDecoded = QUrl::DecodeReserved; // the most decoded mode without being fully decoded
+
QTest::newRow("empty") << QUrl() << int(QUrl::FullyEncoded)
<< QString() << QString() << QString()
<< QString() << QString()
@@ -2710,7 +2712,7 @@ void tst_QUrl::componentEncodings_data()
<< "x://user%20name:pass%20word@host/path%20name?query%20value#fragment%20value";
QTest::newRow("decoded-space") << QUrl("x://user%20name:pass%20word@host/path%20name?query%20value#fragment%20value")
- << int(QUrl::MostDecoded)
+ << MostDecoded
<< "user name" << "pass word" << "user name:pass word"
<< "host" << "user name:pass word@host"
<< "/path name" << "query value" << "fragment value"
@@ -2719,7 +2721,7 @@ void tst_QUrl::componentEncodings_data()
// binary data is always encoded
// this is also testing non-UTF8 data
QTest::newRow("binary") << QUrl("x://%c0%00:%c1%01@host/%c2%02?%c3%03#%d4%04")
- << int(QUrl::MostDecoded)
+ << MostDecoded
<< "%C0%00" << "%C1%01" << "%C0%00:%C1%01"
<< "host" << "%C0%00:%C1%01@host"
<< "/%C2%02" << "%C3%03" << "%D4%04"
@@ -2734,7 +2736,7 @@ void tst_QUrl::componentEncodings_data()
<< "/%E0%A0%80" << "%F0%90%80%80" << "%C3%A9"
<< "x://%C2%80:%C3%90@xn--smrbrd-cyad.example.no/%E0%A0%80?%F0%90%80%80#%C3%A9";
QTest::newRow("decoded-unicode") << QUrl("x://%C2%80:%C3%90@XN--SMRBRD-cyad.example.NO/%E0%A0%80?%F0%90%80%80#%C3%A9")
- << int(QUrl::MostDecoded)
+ << MostDecoded
<< QString::fromUtf8("\xc2\x80") << QString::fromUtf8("\xc3\x90")
<< QString::fromUtf8("\xc2\x80:\xc3\x90")
<< QString::fromUtf8("smørbrød.example.no")
@@ -2770,7 +2772,7 @@ void tst_QUrl::componentEncodings_data()
// 1) test the delimiters that must appear encoded
// (if they were decoded, they'd would change the URL parsing)
QTest::newRow("encoded-gendelims-changing") << QUrl("x://%5b%3a%2f%3f%23%40%5d:%5b%2f%3f%23%40%5d@host/%2f%3f%23?%23")
- << int(QUrl::MostDecoded)
+ << MostDecoded
<< "[:/?#@]" << "[/?#@]" << "[%3A/?#@]:[/?#@]"
<< "host" << "%5B%3A/?#%40%5D:%5B/?#%40%5D@host"
<< "/%2F?#" << "#" << ""
@@ -2797,7 +2799,7 @@ void tst_QUrl::componentEncodings_data()
// 4) like above, but now decode them, which is allowed
QTest::newRow("decoded-square-brackets") << QUrl("x:/%5B%5D#%5B%5D")
- << int(QUrl::MostDecoded)
+ << MostDecoded
<< "" << "" << ""
<< "" << ""
<< "/[]" << "" << "[]"
@@ -2814,7 +2816,7 @@ void tst_QUrl::componentEncodings_data()
<< QString() << "!$()*+,;=:/?[]@%21%24%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D" << QString()
<< "?!$()*+,;=:/?[]@%21%24%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D";
QTest::newRow("undecoded-delims-query") << QUrl("?!$()*+,;=:/?[]@%21%24%26%27%28%29%2a%2b%2c%2f%3a%3b%3d%3f%40%5b%5d")
- << int(QUrl::MostDecoded)
+ << MostDecoded
<< QString() << QString() << QString()
<< QString() << QString()
<< QString() << "!$()*+,;=:/?[]@%21%24%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D" << QString()
diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
index 43266f185b..68aaa198a8 100644
--- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
+++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp
@@ -822,7 +822,9 @@ static void addUtf8Data(const char *name, const char *data)
QString encoded = QByteArray(data).toPercentEncoding();
QString decoded = QString::fromUtf8(data);
- QTest::newRow(QByteArray("decode-") + name) << encoded << QUrl::ComponentFormattingOptions(QUrl::MostDecoded) << decoded;
+ // this data contains invaild UTF-8 sequences, so FullyDecoded doesn't work (by design)
+ // use PrettyDecoded instead
+ QTest::newRow(QByteArray("decode-") + name) << encoded << QUrl::ComponentFormattingOptions(QUrl::PrettyDecoded) << decoded;
QTest::newRow(QByteArray("encode-") + name) << decoded << QUrl::ComponentFormattingOptions(QUrl::FullyEncoded) << encoded;
}
@@ -898,21 +900,21 @@ void tst_QUrlInternal::encodingRecode_data()
}
// encode control characters
- QTest::newRow("encode-control") << "\1abc\2\033esc" << F(QUrl::MostDecoded) << "%01abc%02%1Besc";
- QTest::newRow("encode-nul") << QString::fromLatin1("abc\0def", 7) << F(QUrl::MostDecoded) << "abc%00def";
+ QTest::newRow("encode-control") << "\1abc\2\033esc" << F(QUrl::PrettyDecoded) << "%01abc%02%1Besc";
+ QTest::newRow("encode-nul") << QString::fromLatin1("abc\0def", 7) << F(QUrl::PrettyDecoded) << "abc%00def";
// space
- QTest::newRow("space-leave-decoded") << "Hello World " << F(QUrl::MostDecoded) << "Hello World ";
+ QTest::newRow("space-leave-decoded") << "Hello World " << F(QUrl::PrettyDecoded) << "Hello World ";
QTest::newRow("space-leave-encoded") << "Hello%20World%20" << F(QUrl::FullyEncoded) << "Hello%20World%20";
QTest::newRow("space-encode") << "Hello World " << F(QUrl::FullyEncoded) << "Hello%20World%20";
- QTest::newRow("space-decode") << "Hello%20World%20" << F(QUrl::MostDecoded) << "Hello World ";
+ QTest::newRow("space-decode") << "Hello%20World%20" << F(QUrl::PrettyDecoded) << "Hello World ";
// decode unreserved
QTest::newRow("unreserved-decode") << "%66%6f%6f%42a%72" << F(QUrl::FullyEncoded) << "fooBar";
// mix encoding with decoding
- QTest::newRow("encode-control-decode-space") << "\1\2%200" << F(QUrl::MostDecoded) << "%01%02 0";
- QTest::newRow("decode-space-encode-control") << "%20\1\2" << F(QUrl::MostDecoded) << " %01%02";
+ QTest::newRow("encode-control-decode-space") << "\1\2%200" << F(QUrl::PrettyDecoded) << "%01%02 0";
+ QTest::newRow("decode-space-encode-control") << "%20\1\2" << F(QUrl::PrettyDecoded) << " %01%02";
// decode and encode valid UTF-8 data
// invalid is tested in encodingRecodeInvalidUtf8
@@ -947,11 +949,11 @@ void tst_QUrlInternal::encodingRecode_data()
QTest::newRow("ff") << "%ff" << F(QUrl::FullyEncoded) << "%FF";
// decode UTF-8 mixed with non-UTF-8 and unreserved
- QTest::newRow("utf8-mix-1") << "%80%C2%80" << F(QUrl::MostDecoded) << QString::fromUtf8("%80\xC2\x80");
- QTest::newRow("utf8-mix-2") << "%C2%C2%80" << F(QUrl::MostDecoded) << QString::fromUtf8("%C2\xC2\x80");
- QTest::newRow("utf8-mix-3") << "%E0%C2%80" << F(QUrl::MostDecoded) << QString::fromUtf8("%E0\xC2\x80");
- QTest::newRow("utf8-mix-3") << "A%C2%80" << F(QUrl::MostDecoded) << QString::fromUtf8("A\xC2\x80");
- QTest::newRow("utf8-mix-3") << "%C2%80A" << F(QUrl::MostDecoded) << QString::fromUtf8("\xC2\x80""A");
+ QTest::newRow("utf8-mix-1") << "%80%C2%80" << F(QUrl::PrettyDecoded) << QString::fromUtf8("%80\xC2\x80");
+ QTest::newRow("utf8-mix-2") << "%C2%C2%80" << F(QUrl::PrettyDecoded) << QString::fromUtf8("%C2\xC2\x80");
+ QTest::newRow("utf8-mix-3") << "%E0%C2%80" << F(QUrl::PrettyDecoded) << QString::fromUtf8("%E0\xC2\x80");
+ QTest::newRow("utf8-mix-3") << "A%C2%80" << F(QUrl::PrettyDecoded) << QString::fromUtf8("A\xC2\x80");
+ QTest::newRow("utf8-mix-3") << "%C2%80A" << F(QUrl::PrettyDecoded) << QString::fromUtf8("\xC2\x80""A");
}
void tst_QUrlInternal::encodingRecode()
@@ -993,7 +995,7 @@ void tst_QUrlInternal::encodingRecodeInvalidUtf8()
// prepend some data to be sure that it remains there
QString output = QTest::currentDataTag();
- if (!qt_urlRecode(output, input.constData(), input.constData() + input.length(), QUrl::MostDecoded))
+ if (!qt_urlRecode(output, input.constData(), input.constData() + input.length(), QUrl::PrettyDecoded))
output += input;
QCOMPARE(output, QTest::currentDataTag() + input);
diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
index 7148a71153..c8766f13e5 100644
--- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
+++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp
@@ -626,7 +626,7 @@ void tst_QUrlQuery::encodedSetQueryItems_data()
// plus signs must not be touched
QTest::newRow("encode-plus") << "+=+" << "+" << "+" << F(QUrl::FullyEncoded)
<< "+=+" << "+" << "+";
- QTest::newRow("decode-2b") << "%2b=%2b" << "%2b" << "%2b" << F(QUrl::MostDecoded)
+ QTest::newRow("decode-2b") << "%2b=%2b" << "%2b" << "%2b" << F(QUrl::PrettyDecoded)
<< "%2B=%2B" << "%2B" << "%2B";
@@ -683,7 +683,7 @@ void tst_QUrlQuery::differentDelimiters()
expected << qItem("foo", "bar") << qItem("hello", "world");
COMPARE_ITEMS(query.queryItems(), expected);
COMPARE_ITEMS(query.queryItems(QUrl::FullyEncoded), expected);
- COMPARE_ITEMS(query.queryItems(QUrl::MostDecoded), expected);
+ COMPARE_ITEMS(query.queryItems(QUrl::PrettyDecoded), expected);
}
{