QUrl: fix IDN whitelist checking when the TLD is in Unicode
The whitelist is kept in ACE form, so if the TLD came in Unicode, we need to run ToASCII before we can check the whitelist. This is slightly inefficient because we'll run the same operation later in this domain. Change-Id: Iadfecb6f28984634979dfffd14b831f37b0f4818 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org>bb10
parent
fbb485d4f6
commit
21dd5d314a
|
|
@ -2422,8 +2422,8 @@ static bool qt_is_idn_enabled(const QString &domain)
|
|||
return false;
|
||||
|
||||
int len = domain.size() - idx - 1;
|
||||
QString tldString(domain.constData() + idx + 1, len);
|
||||
qt_nameprep(&tldString, 0);
|
||||
QString tldString = qt_ACE_do(QString::fromRawData(domain.constData() + idx + 1, len), ToAceOnly, ForbidLeadingDot);
|
||||
len = tldString.size();
|
||||
|
||||
const QChar *tld = tldString.constData();
|
||||
|
||||
|
|
|
|||
|
|
@ -670,6 +670,14 @@ void tst_QUrlInternal::ace_testsuite()
|
|||
QCOMPARE(QUrl::fromAce(domain.toLatin1()), fromace + suffix);
|
||||
QCOMPARE(QUrl::fromAce(QUrl::toAce(domain)), unicode + suffix);
|
||||
|
||||
QUrl u;
|
||||
u.setHost(domain);
|
||||
QVERIFY(u.isValid());
|
||||
QCOMPARE(u.host(), unicode + suffix);
|
||||
QCOMPARE(u.host(QUrl::EncodeUnicode), toace + suffix);
|
||||
QCOMPARE(u.toEncoded(), "//" + toace.toLatin1() + suffix);
|
||||
QCOMPARE(u.toDisplayString(), "//" + unicode + suffix);
|
||||
|
||||
domain = in + (suffix ? ".troll.No" : "");
|
||||
QCOMPARE(QString::fromLatin1(QUrl::toAce(domain)), toace + suffix);
|
||||
if (fromace != ".")
|
||||
|
|
|
|||
Loading…
Reference in New Issue