1407 } |
1407 } |
1408 |
1408 |
1409 void tst_QUrl::i18n_data() |
1409 void tst_QUrl::i18n_data() |
1410 { |
1410 { |
1411 QTest::addColumn<QString>("input"); |
1411 QTest::addColumn<QString>("input"); |
1412 QTest::addColumn<QByteArray>("punyOutput"); |
1412 QTest::addColumn<QByteArray>("punyOutput"); |
1413 |
1413 |
1414 QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") |
1414 QTest::newRow("øl") << QString::fromLatin1("http://ole:passord@www.øl.no/index.html?ole=æsemann&ilder gud=hei#top") |
1415 << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); |
1415 << QByteArray("http://ole:passord@www.xn--l-4ga.no/index.html?ole=%C3%A6semann&ilder%20gud=hei#top"); |
1416 QTest::newRow("räksmörgås") << QString::fromLatin1("http://www.räksmörgås.no/") |
1416 QTest::newRow("räksmörgås") << QString::fromLatin1("http://www.räksmörgås.no/") |
1417 << QByteArray("http://www.xn--rksmrgs-5wao1o.no/"); |
1417 << QByteArray("http://www.xn--rksmrgs-5wao1o.no/"); |
2158 QTest::addColumn<QByteArray>("encoded"); |
2162 QTest::addColumn<QByteArray>("encoded"); |
2159 QTest::addColumn<QByteArray>("excludeInEncoding"); |
2163 QTest::addColumn<QByteArray>("excludeInEncoding"); |
2160 QTest::addColumn<QByteArray>("includeInEncoding"); |
2164 QTest::addColumn<QByteArray>("includeInEncoding"); |
2161 |
2165 |
2162 QTest::newRow("test_01") << QString::fromLatin1("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") |
2166 QTest::newRow("test_01") << QString::fromLatin1("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") |
2163 << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") |
2167 << QByteArray("abcdevghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678-._~") |
2164 << QByteArray("") |
2168 << QByteArray("") |
2165 << QByteArray(""); |
2169 << QByteArray(""); |
2166 QTest::newRow("test_02") << QString::fromLatin1("{\t\n\r^\"abc}") |
2170 QTest::newRow("test_02") << QString::fromLatin1("{\t\n\r^\"abc}") |
2167 << QByteArray("%7B%09%0A%0D%5E%22abc%7D") |
2171 << QByteArray("%7B%09%0A%0D%5E%22abc%7D") |
2168 << QByteArray("") |
2172 << QByteArray("") |
2169 << QByteArray(""); |
2173 << QByteArray(""); |
2170 QTest::newRow("test_03") << QString::fromLatin1("://?#[]@!$&'()*+,;=") |
2174 QTest::newRow("test_03") << QString::fromLatin1("://?#[]@!$&'()*+,;=") |
2171 << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") |
2175 << QByteArray("%3A%2F%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D") |
2172 << QByteArray("") |
2176 << QByteArray("") |
2173 << QByteArray(""); |
2177 << QByteArray(""); |
2174 QTest::newRow("test_04") << QString::fromLatin1("://?#[]@!$&'()*+,;=") |
2178 QTest::newRow("test_04") << QString::fromLatin1("://?#[]@!$&'()*+,;=") |
2175 << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") |
2179 << QByteArray("%3A%2F%2F%3F%23%5B%5D%40!$&'()*+,;=") |
2176 << QByteArray("!$&'()*+,;=") |
2180 << QByteArray("!$&'()*+,;=") |
2177 << QByteArray(""); |
2181 << QByteArray(""); |
2178 QTest::newRow("test_05") << QString::fromLatin1("abcd") |
2182 QTest::newRow("test_05") << QString::fromLatin1("abcd") |
2179 << QByteArray("a%62%63d") |
2183 << QByteArray("a%62%63d") |
2180 << QByteArray("") |
2184 << QByteArray("") |
2181 << QByteArray("bc"); |
2185 << QByteArray("bc"); |
2182 } |
2186 } |
2183 |
2187 |
2184 void tst_QUrl::toPercentEncoding() |
2188 void tst_QUrl::toPercentEncoding() |
2185 { |
2189 { |
2186 QFETCH(QString, original); |
2190 QFETCH(QString, original); |
2187 QFETCH(QByteArray, encoded); |
2191 QFETCH(QByteArray, encoded); |
2188 QFETCH(QByteArray, excludeInEncoding); |
2192 QFETCH(QByteArray, excludeInEncoding); |
2189 QFETCH(QByteArray, includeInEncoding); |
2193 QFETCH(QByteArray, includeInEncoding); |
2190 |
2194 |
2191 QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); |
2195 QByteArray encodedUrl = QUrl::toPercentEncoding(original, excludeInEncoding, includeInEncoding); |
2192 QCOMPARE(encodedUrl.constData(), encoded.constData()); |
2196 QCOMPARE(encodedUrl.constData(), encoded.constData()); |
2193 QCOMPARE(original, QUrl::fromPercentEncoding(encodedUrl)); |
2197 QCOMPARE(original, QUrl::fromPercentEncoding(encodedUrl)); |
2194 } |
2198 } |
2195 |
2199 |
2196 void tst_QUrl::symmetry() |
2200 void tst_QUrl::symmetry() |
2454 } |
2458 } |
2455 { |
2459 { |
2456 QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/", QUrl::StrictMode); |
2460 QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/", QUrl::StrictMode); |
2457 QVERIFY(!url.isValid()); |
2461 QVERIFY(!url.isValid()); |
2458 // < and > are not allowed in userinfo in strict mode |
2462 // < and > are not allowed in userinfo in strict mode |
|
2463 url.setUserName("normal_username"); |
|
2464 QVERIFY(url.isValid()); |
2459 } |
2465 } |
2460 { |
2466 { |
2461 QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/"); |
2467 QUrl url = QUrl::fromEncoded("http://strange<username>@ok-hostname/"); |
2462 QVERIFY(url.isValid()); |
2468 QVERIFY(url.isValid()); |
2463 // < and > are allowed in tolerant mode |
2469 // < and > are allowed in tolerant mode |
2464 } |
2470 } |
2465 { |
2471 { |
2466 QUrl url = QUrl::fromEncoded("http://strange;hostname/here"); |
2472 QUrl url = QUrl::fromEncoded("http://strange;hostname/here"); |
2467 QVERIFY(!url.isValid()); |
2473 QVERIFY(!url.isValid()); |
2468 QCOMPARE(url.path(), QString("/here")); |
2474 QCOMPARE(url.path(), QString("/here")); |
2469 } |
2475 url.setAuthority("foobar@bar"); |
|
2476 QVERIFY(url.isValid()); |
|
2477 } |
|
2478 |
|
2479 { |
|
2480 QUrl url = QUrl::fromEncoded("foo://stuff;1/g"); |
|
2481 QVERIFY(!url.isValid()); |
|
2482 QCOMPARE(url.path(), QString("/g")); |
|
2483 url.setHost("stuff-1"); |
|
2484 QVERIFY(url.isValid()); |
|
2485 } |
|
2486 |
2470 } |
2487 } |
2471 |
2488 |
2472 void tst_QUrl::schemeValidator_data() |
2489 void tst_QUrl::schemeValidator_data() |
2473 { |
2490 { |
2474 QTest::addColumn<QByteArray>("encodedUrl"); |
2491 QTest::addColumn<QByteArray>("encodedUrl"); |
3267 QTest::newRow("slash") << "foo/bar" << true; |
3284 QTest::newRow("slash") << "foo/bar" << true; |
3268 QTest::newRow("colon") << "foo:80" << true; |
3285 QTest::newRow("colon") << "foo:80" << true; |
3269 QTest::newRow("question") << "foo?bar" << true; |
3286 QTest::newRow("question") << "foo?bar" << true; |
3270 QTest::newRow("at") << "foo@bar" << true; |
3287 QTest::newRow("at") << "foo@bar" << true; |
3271 QTest::newRow("backslash") << "foo\\bar" << false; |
3288 QTest::newRow("backslash") << "foo\\bar" << false; |
3272 QTest::newRow("underline") << "foo_bar" << false; |
|
3273 |
3289 |
3274 // these characters are transformed by NFKC to non-LDH characters |
3290 // these characters are transformed by NFKC to non-LDH characters |
3275 QTest::newRow("dot-like") << QString::fromUtf8("foo\342\200\244bar") << false; // U+2024 ONE DOT LEADER |
3291 QTest::newRow("dot-like") << QString::fromUtf8("foo\342\200\244bar") << false; // U+2024 ONE DOT LEADER |
3276 QTest::newRow("slash-like") << QString::fromUtf8("foo\357\274\217bar") << false; // U+FF0F FULLWIDTH SOLIDUS |
3292 QTest::newRow("slash-like") << QString::fromUtf8("foo\357\274\217bar") << false; // U+FF0F FULLWIDTH SOLIDUS |
3277 |
3293 |