QUrl: fix host(FullyDecoded), it shouldn't trigger EncodeUnicode.
Change-Id: I9a62d5eb8b099b659cfcfc591c983b3d73ca9569 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
028def2ada
commit
f874a5dd8b
@ -1089,8 +1089,11 @@ inline void QUrlPrivate::setQuery(const QString &value, int from, int iend)
|
||||
|
||||
inline void QUrlPrivate::appendHost(QString &appendTo, QUrl::FormattingOptions options) const
|
||||
{
|
||||
// this is the only flag that matters
|
||||
options &= QUrl::EncodeUnicode;
|
||||
// EncodeUnicode is the only flag that matters
|
||||
if ((options & QUrl::FullyDecoded) == QUrl::FullyDecoded)
|
||||
options = 0;
|
||||
else
|
||||
options &= QUrl::EncodeUnicode;
|
||||
if (host.isEmpty())
|
||||
return;
|
||||
if (host.at(0).unicode() == '[') {
|
||||
|
@ -148,6 +148,8 @@ private slots:
|
||||
void stripTrailingSlash();
|
||||
void hosts_data();
|
||||
void hosts();
|
||||
void hostFlags_data();
|
||||
void hostFlags();
|
||||
void setPort();
|
||||
void toEncoded_data();
|
||||
void toEncoded();
|
||||
@ -2637,6 +2639,29 @@ void tst_QUrl::hosts()
|
||||
QTEST(QUrl(url).host(), "host");
|
||||
}
|
||||
|
||||
void tst_QUrl::hostFlags_data()
|
||||
{
|
||||
QTest::addColumn<QString>("urlStr");
|
||||
QTest::addColumn<QUrl::FormattingOptions>("options");
|
||||
QTest::addColumn<QString>("expectedHost");
|
||||
|
||||
QString swedish = QString::fromUtf8("http://www.räksmörgås.se/pub?a=b&a=dø&a=f#vræl");
|
||||
QTest::newRow("se_fullydecoded") << swedish << QUrl::FormattingOptions(QUrl::FullyDecoded) << QString::fromUtf8("www.räksmörgås.se");
|
||||
QTest::newRow("se_fullyencoded") << swedish << QUrl::FormattingOptions(QUrl::FullyEncoded) << QString::fromUtf8("www.xn--rksmrgs-5wao1o.se");
|
||||
QTest::newRow("se_prettydecoded") << swedish << QUrl::FormattingOptions(QUrl::PrettyDecoded) << QString::fromUtf8("www.räksmörgås.se");
|
||||
QTest::newRow("se_encodespaces") << swedish << QUrl::FormattingOptions(QUrl::EncodeSpaces) << QString::fromUtf8("www.räksmörgås.se");
|
||||
}
|
||||
|
||||
void tst_QUrl::hostFlags()
|
||||
{
|
||||
QFETCH(QString, urlStr);
|
||||
QFETCH(QUrl::FormattingOptions, options);
|
||||
QFETCH(QString, expectedHost);
|
||||
|
||||
QUrl url(urlStr);
|
||||
QCOMPARE(url.host(options), expectedHost);
|
||||
}
|
||||
|
||||
void tst_QUrl::setPort()
|
||||
{
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user