From 6130bb22e754eec132e49e5f254bcedc935e69b0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 2 Jul 2013 13:32:38 -0700 Subject: [PATCH] QUrl: Uppercase the version number in IPvFuture We don't know what it might be used for. The RFC for URI says it's an HEXDIG, and since we uppercase all other HEXDIGs already (in percent-encodings...). Change-Id: I56d0a81315576dd98eaa2657c0307d79332543a5 Reviewed-by: David Faure (KDE) --- src/corelib/io/qurl.cpp | 4 ++++ tests/auto/corelib/io/qurl/tst_qurl.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index be4f177515..3c8483029a 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -1105,6 +1105,10 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar // decode the whole string, skipping the "[vH." and "]" which we already know to be there host += QString::fromRawData(begin, 4); + // uppercase the version, if necessary + if (begin[2].unicode() >= 'a') + host[host.length() - 2] = begin[2].unicode() - 0x20; + begin += 4; --end; diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index ad4c0c1224..105485ca5f 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1636,7 +1636,7 @@ void tst_QUrl::ipvfuture_data() QTest::newRow("non-hex-version") << "x://[vz.1234]" << false; QTest::newRow("digit-ver") << "x://[v7.1]" << true << "x://[v7.1]"; - QTest::newRow("lowercase-hex-ver") << "x://[va.1]" << true << "x://[va.1]"; + QTest::newRow("lowercase-hex-ver") << "x://[va.1]" << true << "x://[vA.1]"; QTest::newRow("lowercase-hex-ver") << "x://[vA.1]" << true << "x://[vA.1]"; QTest::newRow("data-digits") << "x://[v7.1234]" << true << "x://[v7.1234]";