Fix encoding of IDN hostnames with QUrl::host
When the formatting parameter wasn't exactly QUrl::EncodeUnicode, it wouldn't encode, despite having to. Change-Id: Id75834dab9ed466e94c7ffff1444bacc08dd109b Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>bb10
parent
7ab0829823
commit
77fb9ca271
|
|
@ -1176,7 +1176,7 @@ inline void QUrlPrivate::appendHost(QString &appendTo, QUrl::FormattingOptions o
|
|||
} else {
|
||||
// this is either an IPv4Address or a reg-name
|
||||
// if it is a reg-name, it is already stored in Unicode form
|
||||
if (options == QUrl::EncodeUnicode)
|
||||
if (options & QUrl::EncodeUnicode && !(options & 0x4000000))
|
||||
appendTo += qt_ACE_do(host, ToAceOnly, AllowLeadingDot);
|
||||
else
|
||||
appendTo += host;
|
||||
|
|
|
|||
|
|
@ -1749,6 +1749,9 @@ void tst_QUrl::symmetry()
|
|||
QUrl url(QString::fromUtf8("http://www.räksmörgås.se/pub?a=b&a=dø&a=f#vræl"));
|
||||
QCOMPARE(url.scheme(), QString::fromLatin1("http"));
|
||||
QCOMPARE(url.host(), QString::fromUtf8("www.räksmörgås.se"));
|
||||
QCOMPARE(url.host(QUrl::EncodeSpaces), QString::fromUtf8("www.räksmörgås.se"));
|
||||
QCOMPARE(url.host(QUrl::EncodeUnicode), QString::fromUtf8("www.xn--rksmrgs-5wao1o.se"));
|
||||
QCOMPARE(url.host(QUrl::EncodeUnicode | QUrl::EncodeSpaces), QString::fromUtf8("www.xn--rksmrgs-5wao1o.se"));
|
||||
QCOMPARE(url.path(), QString::fromLatin1("/pub"));
|
||||
// this will be encoded ...
|
||||
QCOMPARE(url.encodedQuery().constData(), QString::fromLatin1("a=b&a=d%C3%B8&a=f").toLatin1().constData());
|
||||
|
|
|
|||
Loading…
Reference in New Issue