From 8d3cb11261fe9d6ec2e071c959b836f7bfadc33d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Mar 2012 22:11:33 -0300 Subject: Make QUrl handle ambiguous delimiters correctly Refactor the way that QUrl stores and returns the components of the URL so that ambiguous delimiters (gen-delims that could change the meaning of the parsing) are interpreted correctly. Previously, QUrl called "unambiguous" the form found in a full URL, even though each item in isolation could have more characters decoded. Now, instead, store only the fully decoded form. To recreate the compound forms (the full URL, as well as the user info and the authority), we need to do more processing. This commit applies to the user name, password, path and fragment only. The scheme, host and port do not need this work because they are special; the query is handled separately. Change-Id: I5907ba9b8fe048fff23c128be95668c22820663a Reviewed-by: Shane Kearns --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index a5c11469ad..c9f977e11f 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -225,7 +225,7 @@ void tst_QUrl::hashInPath() { QUrl withHashInPath; withHashInPath.setPath(QString::fromLatin1("hi#mum.txt")); - QCOMPARE(withHashInPath.path(), QString::fromLatin1("hi%23mum.txt")); + QCOMPARE(withHashInPath.path(), QString::fromLatin1("hi#mum.txt")); QCOMPARE(withHashInPath.path(QUrl::MostDecoded), QString::fromLatin1("hi#mum.txt")); QCOMPARE(withHashInPath.toString(QUrl::FullyEncoded), QString("hi%23mum.txt")); QCOMPARE(withHashInPath.toDisplayString(QUrl::PreferLocalFile), QString("hi%23mum.txt")); @@ -236,10 +236,9 @@ void tst_QUrl::hashInPath() const QUrl localWithHash = QUrl::fromLocalFile("/hi#mum.txt"); QCOMPARE(localWithHash.toEncoded(), QByteArray("file:///hi%23mum.txt")); QCOMPARE(localWithHash.toString(), QString("file:///hi%23mum.txt")); - QEXPECT_FAIL("", "Regression in the new QUrl, will fix soon", Abort); QCOMPARE(localWithHash.path(), QString::fromLatin1("/hi#mum.txt")); - QCOMPARE(localWithHash.toString(QUrl::PreferLocalFile), QString("/hi#mum.txt")); - QCOMPARE(localWithHash.toDisplayString(QUrl::PreferLocalFile), QString("/hi#mum.txt")); + QCOMPARE(localWithHash.toString(QUrl::PreferLocalFile | QUrl::PrettyDecoded), QString("/hi#mum.txt")); + QCOMPARE(localWithHash.toDisplayString(QUrl::PreferLocalFile | QUrl::PrettyDecoded), QString("/hi#mum.txt")); } void tst_QUrl::unc() @@ -567,7 +566,7 @@ void tst_QUrl::setUrl() { QUrl carsten; carsten.setPath("/home/gis/src/kde/kdelibs/kfile/.#kfiledetailview.cpp.1.18"); - QCOMPARE(carsten.path(), QString::fromLatin1("/home/gis/src/kde/kdelibs/kfile/.%23kfiledetailview.cpp.1.18")); + QCOMPARE(carsten.path(), QString::fromLatin1("/home/gis/src/kde/kdelibs/kfile/.#kfiledetailview.cpp.1.18")); QUrl charles; charles.setPath("/home/charles/foo%20moo"); -- cgit v1.2.3