1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Correctly detect trackers with invalid TLDs or IPv4/IPv6 addresses.

This commit is contained in:
sledgehammer999 2015-05-09 20:04:03 +03:00
parent e378f28fb7
commit 6c579950f6

View File

@ -718,6 +718,10 @@ QString TrackerFiltersList::getHost(const QString &trakcer) const
QUrl url(trakcer); QUrl url(trakcer);
QString longHost = url.host(); QString longHost = url.host();
QString tld = url.topLevelDomain(); QString tld = url.topLevelDomain();
// We get empty tld when it is invalid or an IPv4/IPv6 address,
// so just return the full host
if (tld.isEmpty())
return longHost;
// We want the domain + tld. Subdomains should be disregarded // We want the domain + tld. Subdomains should be disregarded
int index = longHost.lastIndexOf('.', -(tld.size() + 1)); int index = longHost.lastIndexOf('.', -(tld.size() + 1));
if (index == -1) if (index == -1)