From ecffb3cb7ff0f0f3aa547a63c2251699673ed412 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Thu, 13 Apr 2023 13:30:24 +0200 Subject: [PATCH] FeedReader: Fixed download of favicon --- plugins/FeedReader/services/p3FeedReaderThread.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/FeedReader/services/p3FeedReaderThread.cc b/plugins/FeedReader/services/p3FeedReaderThread.cc index 45c869581..130d2fac1 100644 --- a/plugins/FeedReader/services/p3FeedReaderThread.cc +++ b/plugins/FeedReader/services/p3FeedReaderThread.cc @@ -204,8 +204,14 @@ static std::string calculateLink(const std::string &baseLink, const std::string /* calculate link of base link */ std::string resultLink = baseLink; + int hostStart = 0; /* link should begin with "http://" or "https://" */ - if (resultLink.substr(0, 7) != "http://" || resultLink.substr(0, 8) != "https://") { + if (resultLink.substr(0, 7) == "http://") { + hostStart = 7; + } else if (resultLink.substr(0, 8) == "https://") { + hostStart = 8; + } else { + hostStart = 7; resultLink.insert(0, "http://"); } @@ -216,7 +222,7 @@ static std::string calculateLink(const std::string &baseLink, const std::string if (*link.begin() == '/') { /* link begins with "/" */ - size_t found = resultLink.find('/', 7); + size_t found = resultLink.find('/', hostStart); if (found != std::string::npos) { resultLink.erase(found); } @@ -245,7 +251,7 @@ static bool getFavicon(CURLWrapper &CURL, const std::string &url, std::string &i if (code == CURLE_OK) { if (CURL.responseCode() == 200) { std::string contentType = CURL.contentType(); - if (isContentType(contentType, "image/x-icon") || + if (isContentType(contentType, "image/") || isContentType(contentType, "application/octet-stream") || isContentType(contentType, "text/plain")) { if (!vicon.empty()) {