From eaf4438b3511c8380b9b691b656a87a60e342e29 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Tue, 11 Dec 2018 11:42:34 +0200 Subject: Make url normalization closer to common browser behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Firefox, Chrome and various http libraries normalize /./ and /../ from urls, but retain multiple adjacent slashes as is. Qt removes duplicated slashes which makes it impossible to access some web resources that rely on those. Fixes: QTBUG-71973 Change-Id: Ie18ae6ad3264acb252fcd87a754726a8c546e5ec Reviewed-by: Edward Welbourne Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'tests/auto/corelib/io/qdir/tst_qdir.cpp') diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 30f0e447ad..af9c6be432 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -62,12 +62,7 @@ #endif #ifdef QT_BUILD_INTERNAL - -QT_BEGIN_NAMESPACE -extern Q_AUTOTEST_EXPORT QString - qt_normalizePathSegments(const QString &path, bool allowUncPaths, bool *ok = nullptr); -QT_END_NAMESPACE - +#include "private/qdir_p.h" #endif static QByteArray msgDoesNotExist(const QString &name) @@ -1376,7 +1371,7 @@ void tst_QDir::normalizePathSegments() QFETCH(QString, path); QFETCH(UncHandling, uncHandling); QFETCH(QString, expected); - QString cleaned = qt_normalizePathSegments(path, uncHandling == HandleUnc); + QString cleaned = qt_normalizePathSegments(path, uncHandling == HandleUnc ? QDirPrivate::AllowUncPaths : QDirPrivate::DefaultNormalization); QCOMPARE(cleaned, expected); if (path == expected) QVERIFY2(path.isSharedWith(cleaned), "Strings are same but data is not shared"); -- cgit v1.2.3 From dd5e7f1a52c51061ad54e870df7f8e04c0f06fbe Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 5 Nov 2018 16:55:08 +0100 Subject: Use a more robust test for absolute paths in QDir Its filePath() and absoluteFilePath() don't trust its own isAbsolute(), due to some infelicities on MS-Win; and kludged round a consequent problem with resource paths; but other virtual file systems weren't catered for. Replace the convoluted test there with a static bool function (so that future kludges in this area shall only need to edit one place; and can document why they're needed) and use a more robust test that handles all virtual file systems (by asking QFileInfo) but falls back to QFileSystemEntry to work round the known infelicities on MS-Win. Add regression test for asset library paths issue on iOS. Ammends 27f1f84c1c2. Moved a couple of local variables to after the early return, since it doesn't need them, in the process. Task-number: QTBUG-70237 Change-Id: Ib3954826df40ccf816beebe5c3751497e3bf6433 Reviewed-by: Edward Welbourne Reviewed-by: Andy Shaw --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/auto/corelib/io/qdir/tst_qdir.cpp') diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index af9c6be432..34588b19bc 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1523,6 +1523,11 @@ void tst_QDir::filePath_data() QTest::newRow("rel-rel") << "relative" << "path" << "relative/path"; QTest::newRow("empty-empty") << "" << "" << "."; QTest::newRow("resource") << ":/prefix" << "foo.bar" << ":/prefix/foo.bar"; +#ifdef Q_OS_IOS + QTest::newRow("assets-rel") << "assets-library:/" << "foo/bar.baz" << "assets-library:/foo/bar.baz"; + QTest::newRow("assets-abs") << "assets-library:/" << "/foo/bar.baz" << "/foo/bar.baz"; + QTest::newRow("abs-assets") << "/some/path" << "assets-library:/foo/bar.baz" << "assets-library:/foo/bar.baz"; +#endif #ifdef Q_OS_WIN QTest::newRow("abs-LTUNC") << "Q:/path" << "\\/leaning\\tooth/pick" << "\\/leaning\\tooth/pick"; QTest::newRow("LTUNC-slash") << "\\/leaning\\tooth/pick" << "/path" << "//leaning/tooth/path"; -- cgit v1.2.3