tst_qurlinternal: Remove nameprep and STD3 rules tests

IDNA 2008/UTS #46 do not use nameprep anymore and have different
validity rules.

Unexport qt_nameprep() and qt_check_std3rules() because they
are not used by any tests anymore.

Task-number: QTBUG-85323
Change-Id: I38c0dbae9a6bd108fbcfac350767aa7e757e786f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ievgenii Meshcheriakov 2021-08-16 15:49:38 +02:00
parent 5b01399781
commit 655e353557
3 changed files with 2 additions and 329 deletions

View File

@ -66,8 +66,6 @@ extern Q_AUTOTEST_EXPORT qsizetype qt_urlRecode(QString &appendTo, QStringView u
enum AceLeadingDot { AllowLeadingDot, ForbidLeadingDot };
enum AceOperation { ToAceOnly, NormalizeAce };
extern QString qt_ACE_do(QStringView domain, AceOperation op, AceLeadingDot dot);
extern Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from);
extern Q_AUTOTEST_EXPORT bool qt_check_std3rules(QStringView in);
extern Q_AUTOTEST_EXPORT void qt_punycodeEncoder(QStringView in, QString *output);
extern Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc);

View File

@ -2031,7 +2031,7 @@ static bool isBidirectionalL(uint uc)
return false;
}
Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from)
static bool qt_nameprep(QString *source, int from)
{
QChar *src = source->data(); // causes a detach, so we're sure the only one using it
QChar *out = src + from;
@ -2158,7 +2158,7 @@ static const QChar *qt_find_nonstd3(QStringView in, Qt::CaseSensitivity cs)
return nullptr;
}
Q_AUTOTEST_EXPORT bool qt_check_std3rules(QStringView in)
static bool qt_check_std3rules(QStringView in)
{
return qt_find_nonstd3(in, Qt::CaseInsensitive) == nullptr;
}

View File

@ -65,10 +65,6 @@ private Q_SLOTS:
#ifdef QT_BUILD_INTERNAL
void idna_testsuite_data();
void idna_testsuite();
void nameprep_testsuite_data();
void nameprep_testsuite();
void nameprep_highcodes_data();
void nameprep_highcodes();
#endif
void ace_testsuite_data();
void ace_testsuite();
@ -251,313 +247,6 @@ void tst_QUrlInternal::idna_testsuite()
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QUrlInternal::nameprep_testsuite_data()
{
QTest::addColumn<QString>("in");
QTest::addColumn<QString>("out");
QTest::addColumn<QString>("profile");
QTest::addColumn<int>("flags");
QTest::addColumn<int>("rc");
QTest::newRow("Map to nothing")
<< QString::fromUtf8("foo\xC2\xAD\xCD\x8F\xE1\xA0\x86\xE1\xA0\x8B"
"bar""\xE2\x80\x8B\xE2\x81\xA0""baz\xEF\xB8\x80\xEF\xB8\x88"
"\xEF\xB8\x8F\xEF\xBB\xBF")
<< QString::fromUtf8("foobarbaz")
<< QString() << 0 << 0;
QTest::newRow("Case folding ASCII U+0043 U+0041 U+0046 U+0045")
<< QString::fromUtf8("CAFE")
<< QString::fromUtf8("cafe")
<< QString() << 0 << 0;
QTest::newRow("Case folding 8bit U+00DF (german sharp s)")
<< QString::fromUtf8("\xC3\x9F")
<< QString("ss")
<< QString() << 0 << 0;
QTest::newRow("Case folding U+0130 (turkish capital I with dot)")
<< QString::fromUtf8("\xC4\xB0")
<< QString::fromUtf8("i\xcc\x87")
<< QString() << 0 << 0;
QTest::newRow("Case folding multibyte U+0143 U+037A")
<< QString::fromUtf8("\xC5\x83\xCD\xBA")
<< QString::fromUtf8("\xC5\x84 \xCE\xB9")
<< QString() << 0 << 0;
QTest::newRow("Case folding U+2121 U+33C6 U+1D7BB")
<< QString::fromUtf8("\xE2\x84\xA1\xE3\x8F\x86\xF0\x9D\x9E\xBB")
<< QString::fromUtf8("telc\xE2\x88\x95""kg\xCF\x83")
<< QString() << 0 << 0;
QTest::newRow("Normalization of U+006a U+030c U+00A0 U+00AA")
<< QString::fromUtf8("\x6A\xCC\x8C\xC2\xA0\xC2\xAA")
<< QString::fromUtf8("\xC7\xB0 a")
<< QString() << 0 << 0;
QTest::newRow("Case folding U+1FB7 and normalization")
<< QString::fromUtf8("\xE1\xBE\xB7")
<< QString::fromUtf8("\xE1\xBE\xB6\xCE\xB9")
<< QString() << 0 << 0;
QTest::newRow("Self-reverting case folding U+01F0 and normalization")
// << QString::fromUtf8("\xC7\xF0") ### typo in the original testsuite
<< QString::fromUtf8("\xC7\xB0")
<< QString::fromUtf8("\xC7\xB0")
<< QString() << 0 << 0;
QTest::newRow("Self-reverting case folding U+0390 and normalization")
<< QString::fromUtf8("\xCE\x90")
<< QString::fromUtf8("\xCE\x90")
<< QString() << 0 << 0;
QTest::newRow("Self-reverting case folding U+03B0 and normalization")
<< QString::fromUtf8("\xCE\xB0")
<< QString::fromUtf8("\xCE\xB0")
<< QString() << 0 << 0;
QTest::newRow("Self-reverting case folding U+1E96 and normalization")
<< QString::fromUtf8("\xE1\xBA\x96")
<< QString::fromUtf8("\xE1\xBA\x96")
<< QString() << 0 << 0;
QTest::newRow("Self-reverting case folding U+1F56 and normalization")
<< QString::fromUtf8("\xE1\xBD\x96")
<< QString::fromUtf8("\xE1\xBD\x96")
<< QString() << 0 << 0;
QTest::newRow("ASCII space character U+0020")
<< QString::fromUtf8("\x20")
<< QString::fromUtf8("\x20")
<< QString() << 0 << 0;
QTest::newRow("Non-ASCII 8bit space character U+00A0")
<< QString::fromUtf8("\xC2\xA0")
<< QString::fromUtf8("\x20")
<< QString() << 0 << 0;
QTest::newRow("Non-ASCII multibyte space character U+1680")
<< QString::fromUtf8("x\xE1\x9A\x80x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Non-ASCII multibyte space character U+2000")
<< QString::fromUtf8("\xE2\x80\x80")
<< QString::fromUtf8("\x20")
<< QString() << 0 << 0;
QTest::newRow("Zero Width Space U+200b")
<< QString::fromUtf8("\xE2\x80\x8b")
<< QString()
<< QString() << 0 << 0;
QTest::newRow("Non-ASCII multibyte space character U+3000")
<< QString::fromUtf8("\xE3\x80\x80")
<< QString::fromUtf8("\x20")
<< QString() << 0 << 0;
QTest::newRow("ASCII control characters U+0010 U+007F")
<< QString::fromUtf8("\x10\x7F")
<< QString::fromUtf8("\x10\x7F")
<< QString() << 0 << 0;
QTest::newRow("Non-ASCII 8bit control character U+0080")
<< QString::fromUtf8("x\xC2\x80x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Non-ASCII 8bit control character U+0085")
<< QString::fromUtf8("x\xC2\x85x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Non-ASCII multibyte control character U+180E")
<< QString::fromUtf8("x\xE1\xA0\x8Ex")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Zero Width No-Break Space U+FEFF")
<< QString::fromUtf8("\xEF\xBB\xBF")
<< QString()
<< QString() << 0 << 0;
QTest::newRow("Non-ASCII control character U+1D175")
<< QString::fromUtf8("x\xF0\x9D\x85\xB5x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Plane 0 private use character U+F123")
<< QString::fromUtf8("x\xEF\x84\xA3x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Plane 15 private use character U+F1234")
<< QString::fromUtf8("x\xF3\xB1\x88\xB4x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Plane 16 private use character U+10F234")
<< QString::fromUtf8("x\xF4\x8F\x88\xB4x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Non-character code point U+8FFFE")
<< QString::fromUtf8("x\xF2\x8F\xBF\xBEx")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Non-character code point U+10FFFF")
<< QString::fromUtf8("x\xF4\x8F\xBF\xBFx")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Surrogate code U+DF42")
<< QString::fromUtf8("x\xED\xBD\x82x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Non-plain text character U+FFFD")
<< QString::fromUtf8("x\xEF\xBF\xBDx")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Ideographic description character U+2FF5")
<< QString::fromUtf8("x\xE2\xBF\xB5x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Display property character U+0341")
<< QString::fromUtf8("\xCD\x81")
<< QString::fromUtf8("\xCC\x81")
<< QString() << 0 << 0;
QTest::newRow("Left-to-right mark U+200E")
<< QString::fromUtf8("x\xE2\x80\x8Ex")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Deprecated U+202A")
<< QString::fromUtf8("x\xE2\x80\xAA")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Language tagging character U+E0001")
<< QString::fromUtf8("x\xF3\xA0\x80\x81x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Language tagging character U+E0042")
<< QString::fromUtf8("x\xF3\xA0\x81\x82x")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED;
QTest::newRow("Bidi: RandALCat character U+05BE and LCat characters")
<< QString::fromUtf8("foo\xD6\xBE""bar")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_BIDI_BOTH_L_AND_RAL;
QTest::newRow("Bidi: RandALCat character U+FD50 and LCat characters")
<< QString::fromUtf8("foo\xEF\xB5\x90""bar")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_BIDI_BOTH_L_AND_RAL;
QTest::newRow("Bidi: RandALCat character U+FB38 and LCat characters")
<< QString::fromUtf8("foo\xEF\xB9\xB6""bar")
<< QString::fromUtf8("foo \xd9\x8e""bar")
<< QString() << 0 << 0;
QTest::newRow("Bidi: RandALCat without trailing RandALCat U+0627 U+0031")
<< QString::fromUtf8("\xD8\xA7\x31")
<< QString()
<< QString("Nameprep") << 0 << STRINGPREP_BIDI_LEADTRAIL_NOT_RAL;
QTest::newRow("Bidi: RandALCat character U+0627 U+0031 U+0628")
<< QString::fromUtf8("\xD8\xA7\x31\xD8\xA8")
<< QString::fromUtf8("\xD8\xA7\x31\xD8\xA8")
<< QString() << 0 << 0;
QTest::newRow("Unassigned code point U+E0002")
<< QString::fromUtf8("\xF3\xA0\x80\x82")
<< QString()
<< QString("Nameprep") << STRINGPREP_NO_UNASSIGNED << STRINGPREP_CONTAINS_UNASSIGNED;
QTest::newRow("Larger test (shrinking)")
<< QString::fromUtf8("X\xC2\xAD\xC3\x9F\xC4\xB0\xE2\x84\xA1\x6a\xcc\x8c\xc2\xa0\xc2"
"\xaa\xce\xb0\xe2\x80\x80")
<< QString::fromUtf8("xssi\xcc\x87""tel\xc7\xb0 a\xce\xb0 ")
<< QString("Nameprep") << 0 << 0;
QTest::newRow("Larger test (expanding)")
<< QString::fromUtf8("X\xC3\x9F\xe3\x8c\x96\xC4\xB0\xE2\x84\xA1\xE2\x92\x9F\xE3\x8c\x80")
<< QString::fromUtf8("xss\xe3\x82\xad\xe3\x83\xad\xe3\x83\xa1\xe3\x83\xbc\xe3\x83\x88"
"\xe3\x83\xab""i\xcc\x87""tel\x28""d\x29\xe3\x82\xa2\xe3\x83\x91"
"\xe3\x83\xbc\xe3\x83\x88")
<< QString() << 0 << 0;
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QUrlInternal::nameprep_testsuite()
{
QFETCH(QString, in);
QFETCH(QString, out);
QFETCH(QString, profile);
qt_nameprep(&in, 0);
QCOMPARE(in, out);
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QUrlInternal::nameprep_highcodes_data()
{
QTest::addColumn<QString>("in");
QTest::addColumn<QString>("out");
QTest::addColumn<QString>("profile");
QTest::addColumn<int>("flags");
QTest::addColumn<int>("rc");
{
QChar st[] = { '-', QChar(0xd801), QChar(0xdc1d), 'a' };
QChar se[] = { '-', QChar(0xd801), QChar(0xdc45), 'a' };
QTest::newRow("highcodes (U+1041D)")
<< QString(st, sizeof(st)/sizeof(st[0]))
<< QString(se, sizeof(se)/sizeof(se[0]))
<< QString() << 0 << 0;
}
{
QChar st[] = { QChar(0x011C), QChar(0xd835), QChar(0xdf6e), QChar(0x0110) };
QChar se[] = { QChar(0x011D), QChar(0x03C9), QChar(0x0111) };
QTest::newRow("highcodes (U+1D76E)")
<< QString(st, sizeof(st)/sizeof(st[0]))
<< QString(se, sizeof(se)/sizeof(se[0]))
<< QString() << 0 << 0;
}
{
QChar st[] = { 'D', 'o', '\'', QChar(0x2060), 'h' };
QChar se[] = { 'd', 'o', '\'', 'h' };
QTest::newRow("highcodes (D, o, ', U+2060, h)")
<< QString(st, sizeof(st)/sizeof(st[0]))
<< QString(se, sizeof(se)/sizeof(se[0]))
<< QString() << 0 << 0;
}
}
#endif
#ifdef QT_BUILD_INTERNAL
void tst_QUrlInternal::nameprep_highcodes()
{
QFETCH(QString, in);
QFETCH(QString, out);
QFETCH(QString, profile);
qt_nameprep(&in, 0);
QCOMPARE(in, out);
}
#endif
void tst_QUrlInternal::ace_testsuite_data()
{
QTest::addColumn<QString>("in");
@ -741,9 +430,6 @@ void tst_QUrlInternal::std3violations_data()
QTest::newRow("control") << "\033foo" << false;
QTest::newRow("bang") << "foo!" << false;
QTest::newRow("plus") << "foo+bar" << false;
QTest::newRow("dot") << "foo.bar";
QTest::newRow("startingdot") << ".bar" << false;
QTest::newRow("startingdot2") << ".example.com" << false;
QTest::newRow("slash") << "foo/bar" << true;
QTest::newRow("colon") << "foo:80" << true;
QTest::newRow("question") << "foo?bar" << true;
@ -764,17 +450,6 @@ void tst_QUrlInternal::std3violations()
{
QFETCH(QString, source);
#ifdef QT_BUILD_INTERNAL
{
QString prepped = source;
qt_nameprep(&prepped, 0);
QVERIFY(!qt_check_std3rules(prepped));
}
#endif
if (source.contains('.'))
return; // this test ends here
QUrl url;
url.setHost(source);
QVERIFY(url.host().isEmpty());