FeedReader: Fixed download of favicon

This commit is contained in:
thunder2 2023-04-13 13:30:24 +02:00
parent 7070a6cad6
commit ecffb3cb7f

View file

@ -204,8 +204,14 @@ static std::string calculateLink(const std::string &baseLink, const std::string
/* calculate link of base link */ /* calculate link of base link */
std::string resultLink = baseLink; std::string resultLink = baseLink;
int hostStart = 0;
/* link should begin with "http://" or "https://" */ /* 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://"); resultLink.insert(0, "http://");
} }
@ -216,7 +222,7 @@ static std::string calculateLink(const std::string &baseLink, const std::string
if (*link.begin() == '/') { if (*link.begin() == '/') {
/* link begins with "/" */ /* link begins with "/" */
size_t found = resultLink.find('/', 7); size_t found = resultLink.find('/', hostStart);
if (found != std::string::npos) { if (found != std::string::npos) {
resultLink.erase(found); resultLink.erase(found);
} }
@ -245,7 +251,7 @@ static bool getFavicon(CURLWrapper &CURL, const std::string &url, std::string &i
if (code == CURLE_OK) { if (code == CURLE_OK) {
if (CURL.responseCode() == 200) { if (CURL.responseCode() == 200) {
std::string contentType = CURL.contentType(); std::string contentType = CURL.contentType();
if (isContentType(contentType, "image/x-icon") || if (isContentType(contentType, "image/") ||
isContentType(contentType, "application/octet-stream") || isContentType(contentType, "application/octet-stream") ||
isContentType(contentType, "text/plain")) { isContentType(contentType, "text/plain")) {
if (!vicon.empty()) { if (!vicon.empty()) {