summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-05-08 16:36:26 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-05-08 21:48:14 (GMT)
commit75f0c1f0f0496ae22ed89b996dfb0050defd0f3e (patch)
treedcd8e9f5e83b6ae3d51ba821df0e36037b6256c1
parent79533291672fd5e6ddafe5be90501cbe2ec97b1b (diff)
downloadQt-75f0c1f0f0496ae22ed89b996dfb0050defd0f3e.zip
Qt-75f0c1f0f0496ae22ed89b996dfb0050defd0f3e.tar.gz
Qt-75f0c1f0f0496ae22ed89b996dfb0050defd0f3e.tar.bz2
QUrl: fix parsing of IRIs with more than one IDN label
Task-number: QTBUG-10511 Reviewed-by: Trust Me
-rw-r--r--src/corelib/io/qurl.cpp1
-rw-r--r--tests/auto/qurl/tst_qurl.cpp26
2 files changed, 27 insertions, 0 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 3604648..bdb0cfd 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3308,6 +3308,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);
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index 83109b5..8dffebb 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -3189,6 +3189,32 @@ void tst_QUrl::ace_testsuite_data()
QTest::newRow("separator-3002") << QString::fromUtf8("example\343\200\202com")
<< "example.com" << "." << "example.com";
+
+ QString egyptianIDN =
+ QString::fromUtf8("\331\210\330\262\330\247\330\261\330\251\055\330\247\331\204\330"
+ "\243\330\252\330\265\330\247\331\204\330\247\330\252.\331\205"
+ "\330\265\330\261");
+ QTest::newRow("egyptian-tld-ace")
+ << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c"
+ << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c"
+ << "."
+ << egyptianIDN;
+ QTest::newRow("egyptian-tld-unicode")
+ << egyptianIDN
+ << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c"
+ << "."
+ << egyptianIDN;
+ QTest::newRow("egyptian-tld-mix1")
+ << QString::fromUtf8("\331\210\330\262\330\247\330\261\330\251\055\330\247\331\204\330"
+ "\243\330\252\330\265\330\247\331\204\330\247\330\252.xn--wgbh1c")
+ << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c"
+ << "."
+ << egyptianIDN;
+ QTest::newRow("egyptian-tld-mix2")
+ << QString::fromUtf8("xn----rmckbbajlc6dj7bxne2c.\331\205\330\265\330\261")
+ << "xn----rmckbbajlc6dj7bxne2c.xn--wgbh1c"
+ << "."
+ << egyptianIDN;
}
void tst_QUrl::ace_testsuite()