diff options
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r-- | src/corelib/io/qurl.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index d4b8b5f..79a8ce4 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -345,6 +345,7 @@ public: bool hasQuery; bool hasFragment; bool isValid; + bool isHostValid; char valueDelimiter; char pairDelimiter; @@ -3138,10 +3139,11 @@ static void toPunycodeHelper(const QChar *s, int ucLength, QString *output) static const char * const idn_whitelist[] = { - "ac", "at", - "br", + "ac", "ar", "at", + "biz", "br", "cat", "ch", "cl", "cn", "de", "dk", + "es", "fi", "gr", "hu", @@ -3155,6 +3157,9 @@ static const char * const idn_whitelist[] = { "se", "sh", "th", "tm", "tw", "vn", + "xn--mgbaam7a8h", // UAE + "xn--mgberp4a5d4ar", // Saudi Arabia + "xn--wgbh1c" // Egypt }; static QStringList *user_idn_whitelist = 0; @@ -3313,6 +3318,7 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) qt_nameprep(&result, prevLen); labelLength = result.length() - prevLen; register int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes + aceForm.resize(0); if (toReserve > aceForm.capacity()) aceForm.reserve(toReserve); toPunycodeHelper(result.constData() + prevLen, result.size() - prevLen, &aceForm); @@ -3349,6 +3355,7 @@ QUrlPrivate::QUrlPrivate() ref = 1; port = -1; isValid = false; + isHostValid = true; parsingMode = QUrl::TolerantMode; valueDelimiter = '='; pairDelimiter = '&'; @@ -3375,6 +3382,7 @@ QUrlPrivate::QUrlPrivate(const QUrlPrivate ©) hasQuery(copy.hasQuery), hasFragment(copy.hasFragment), isValid(copy.isValid), + isHostValid(copy.isHostValid), valueDelimiter(copy.valueDelimiter), pairDelimiter(copy.pairDelimiter), stateFlags(copy.stateFlags), @@ -3405,6 +3413,8 @@ QString QUrlPrivate::canonicalHost() const that->host = host.toLower(); } else { that->host = qt_ACE_do(host, NormalizeAce); + if (that->host.isNull()) + that->isHostValid = false; } return that->host; } @@ -3481,6 +3491,7 @@ QString QUrlPrivate::authority(QUrl::FormattingOptions options) const void QUrlPrivate::setAuthority(const QString &auth) { + isHostValid = true; if (auth.isEmpty()) { setUserInfo(QString()); host.clear(); @@ -4175,7 +4186,7 @@ bool QUrl::isValid() const if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Validated)) d->validate(); - return d->isValid; + return d->isValid && d->isHostValid; } /*! @@ -4427,7 +4438,6 @@ void QUrl::setAuthority(const QString &authority) if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); detach(); QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized); - d->setAuthority(authority); } @@ -4648,6 +4658,7 @@ void QUrl::setHost(const QString &host) if (!d) d = new QUrlPrivate; if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); detach(); + d->isHostValid = true; QURL_UNSETFLAG(d->stateFlags, QUrlPrivate::Validated | QUrlPrivate::Normalized | QUrlPrivate::HostCanonicalized); d->host = host; |