From cd42236540c1cfca332c0f051d981acfdacf7b4e Mon Sep 17 00:00:00 2001 From: Jessy2027 <89694096+jessy2027@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:17:16 +0100 Subject: [PATCH] Fix UI freeze when downloading favicons with slow DNS IconDownloader::setUrl resolved the entry's host name with the blocking QHostInfo::fromName on the GUI thread, only to find out whether the host is an IP address. When the DNS servers are slow or unreachable, the whole window stopped responding until the lookup timed out. Check the host with UrlTools::isIpAddress instead, which parses the literal address without any network access. Also add IPv6 literal cases to the icon downloader tests. Fixes #13989 --- src/gui/IconDownloader.cpp | 12 +++--------- tests/TestIconDownloader.cpp | 4 ++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gui/IconDownloader.cpp b/src/gui/IconDownloader.cpp index 42b1b09af..d1e8c7c24 100644 --- a/src/gui/IconDownloader.cpp +++ b/src/gui/IconDownloader.cpp @@ -21,7 +21,6 @@ #include "networking/NetworkManager.h" #include -#include #include #include @@ -72,14 +71,9 @@ void IconDownloader::setUrl(const QString& entryUrl) QString fullyQualifiedDomain = url.host(); - // Determine if host portion of URL is an IP address by resolving it and - // searching for a match with the returned address(es). - bool hostIsIp = false; - QList hostAddresses = QHostInfo::fromName(fullyQualifiedDomain).addresses(); - hostIsIp = - std::any_of(hostAddresses.begin(), hostAddresses.end(), [&fullyQualifiedDomain](const QHostAddress& addr) { - return addr.toString() == fullyQualifiedDomain; - }); + // Determine if host portion of URL is an IP address. This must not resolve the + // host name, as a blocking DNS lookup would freeze the UI. + const bool hostIsIp = UrlTools::isIpAddress(fullyQualifiedDomain); // Determine the second-level domain, if available QString secondLevelDomain; diff --git a/tests/TestIconDownloader.cpp b/tests/TestIconDownloader.cpp index 44aebd74c..d912834a4 100644 --- a/tests/TestIconDownloader.cpp +++ b/tests/TestIconDownloader.cpp @@ -97,6 +97,10 @@ void TestIconDownloader::testIconDownloader_data() << QStringList{"https://user:password@de.login.keepassxc.org/favicon.ico", "https://user:password@keepassxc.org/favicon.ico", "https://keepassxc.org/favicon.ico"}; + QTest::newRow("Raw IPv6 with schema") + << "https://[2001:db8::1]" << QStringList{"https://[2001:db8::1]/favicon.ico"}; + QTest::newRow("Raw IPv6 with schema and port") + << "https://[2001:db8::1]:8080" << QStringList{"https://[2001:db8::1]:8080/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")