From 170469ef84fd7ce7805ff174aed5b3447fa8e7a2 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 1 Jul 2013 15:12:36 +0200 Subject: [PATCH] Fix QUrl::topLevelDomain(QUrl::FullyDecoded) qt_ACE_do(".co.uk") was returning an empty string because of the leading dot. This has always caused issues in KDE code too, where ACE normalization needs the dot removed, and re-added afterwards. Change-Id: Id9fcea0333cf55c14d755a86d4bf33a50f194429 Reviewed-by: Frederik Gladhorn --- src/corelib/io/qurlidna.cpp | 3 ++- tests/auto/corelib/io/qurl/tst_qurl.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index 70db9e09eb..619ab589a4 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -2479,7 +2479,8 @@ QString qt_ACE_do(const QString &domain, AceOperation op) if (labelLength == 0) { if (idx == domain.length()) break; - return QString(); // two delimiters in a row -- empty label not allowed + if (idx > 0) + return QString(); // two delimiters in a row -- empty label not allowed } // RFC 3490 says, about the ToASCII operation: diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 2a79a6963e..23f245a5ae 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -2863,7 +2863,8 @@ void tst_QUrl::effectiveTLDs() { QFETCH(QUrl, domain); QFETCH(QString, TLD); - QCOMPARE(domain.topLevelDomain(), TLD); + QCOMPARE(domain.topLevelDomain(QUrl::PrettyDecoded), TLD); + QCOMPARE(domain.topLevelDomain(QUrl::FullyDecoded), TLD); } void tst_QUrl::lowercasesScheme()