Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Klein <42714034+libklein@users.noreply.github.com>2022-10-20 03:50:17 +0300
committerJonathan White <support@dmapps.us>2022-10-20 03:51:54 +0300
commit047251a07f3a86e7a0546c4e5215902b4748a230 (patch)
treee9187938959a7a50e59bb2a95875360e65671763
parenta6db8ba2db78a8385bc64c043c1cd7787fb61d97 (diff)
Add a URL that preserves the URL path when trying to resolve favicons. (#8565)
-rw-r--r--src/gui/IconDownloader.cpp7
-rw-r--r--tests/TestIconDownloader.cpp18
2 files changed, 20 insertions, 5 deletions
diff --git a/src/gui/IconDownloader.cpp b/src/gui/IconDownloader.cpp
index d9a8e693b..7e3fff0ae 100644
--- a/src/gui/IconDownloader.cpp
+++ b/src/gui/IconDownloader.cpp
@@ -130,6 +130,13 @@ void IconDownloader::setUrl(const QString& entryUrl)
}
}
+ // Add a pull that preserves the query if there is one.
+ if (!url.path().isEmpty()) {
+ // Appends /favicon.ico to the last segment of the path.
+ // stem/something/ will become stem/something/favicon.ico, and stem/something will become stem/favicon.ico
+ m_urlsToTry.append(url.resolved(QUrl("./favicon.ico")));
+ }
+
// Add a direct pull of the website's own favicon.ico file
QUrl favicon_url = url;
favicon_url.setPath("/favicon.ico");
diff --git a/tests/TestIconDownloader.cpp b/tests/TestIconDownloader.cpp
index a0a1fa491..77b21e3e7 100644
--- a/tests/TestIconDownloader.cpp
+++ b/tests/TestIconDownloader.cpp
@@ -30,9 +30,11 @@ void TestIconDownloader::testIconDownloader_data()
QTest::newRow("Unsupported schema") << "ftp://google.com" << QStringList{};
QTest::newRow("Missing schema") << "keepassxc.org" << QStringList{"https://keepassxc.org/favicon.ico"};
QTest::newRow("Missing host") << "https:///register" << QStringList{};
- QTest::newRow("URL with path") << "https://keepassxc.org/register/here" << QStringList{keepassxc_favicon};
+ QTest::newRow("URL with path") << "https://keepassxc.org/register/here/"
+ << QStringList{"https://keepassxc.org/register/here/favicon.ico", keepassxc_favicon};
QTest::newRow("URL with path and query")
- << "https://keepassxc.org/register/here?login=me" << QStringList{keepassxc_favicon};
+ << "https://keepassxc.org/register/here?login=me"
+ << QStringList{"https://keepassxc.org/register/favicon.ico", keepassxc_favicon};
QTest::newRow("URL with port") << "https://keepassxc.org:8080"
<< QStringList{"https://keepassxc.org:8080/favicon.ico"};
QTest::newRow("2nd level domain") << "https://login.keepassxc.org"
@@ -54,11 +56,14 @@ void TestIconDownloader::testIconDownloader_data()
<< QStringList{"https://134.130.155.184/favicon.ico"};
QTest::newRow("Raw IP") << "134.130.155.184" << QStringList{"https://134.130.155.184/favicon.ico"};
QTest::newRow("Raw IP with schema and path")
- << "https://134.130.155.184/with/path" << QStringList{"https://134.130.155.184/favicon.ico"};
+ << "https://134.130.155.184/with/path/"
+ << QStringList{"https://134.130.155.184/with/path/favicon.ico", "https://134.130.155.184/favicon.ico"};
QTest::newRow("Raw IP with schema (https), path, and port")
- << "https://134.130.155.184:8080/test" << QStringList{"https://134.130.155.184:8080/favicon.ico"};
+ << "https://134.130.155.184:8080/test/"
+ << QStringList{"https://134.130.155.184:8080/test/favicon.ico", "https://134.130.155.184:8080/favicon.ico"};
QTest::newRow("Raw IP with schema (http), path, and port")
- << "134.130.155.184:8080/test" << QStringList{"https://134.130.155.184:8080/favicon.ico"};
+ << "134.130.155.184:8080/test/"
+ << QStringList{"https://134.130.155.184:8080/test/favicon.ico", "https://134.130.155.184:8080/favicon.ico"};
QTest::newRow("URL with username and password")
<< "https://user:password@keepassxc.org" << QStringList{"https://user:password@keepassxc.org/favicon.ico"};
QTest::newRow("URL with username and password, several subdomains")
@@ -68,4 +73,7 @@ void TestIconDownloader::testIconDownloader_data()
"https://keepassxc.org/favicon.ico"};
QTest::newRow("Raw IP with username and password")
<< "https://user:password@134.130.155.184" << QStringList{"https://user:password@134.130.155.184/favicon.ico"};
+ QTest::newRow("Relative path should be preserved")
+ << "https://test.com/rel-path/"
+ << QStringList{"https://test.com/rel-path/favicon.ico", "https://test.com/favicon.ico"};
}