From 03d80ea9fc9adbf8d2e3ee947d2216d2e267cb8b Mon Sep 17 00:00:00 2001 From: Alex Jbanca Date: Fri, 10 Feb 2023 13:07:54 +0200 Subject: [PATCH] fix(LinksMessageView): Remove HEAD validation for image urls --- src/app_service/service/message/async_tasks.nim | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/app_service/service/message/async_tasks.nim b/src/app_service/service/message/async_tasks.nim index c89a3fac46..a237998ed6 100644 --- a/src/app_service/service/message/async_tasks.nim +++ b/src/app_service/service/message/async_tasks.nim @@ -1,4 +1,4 @@ -import std/uri, std/httpclient +import std/uri include ../../common/json_utils include ../../../app/core/tasks/common @@ -173,7 +173,6 @@ const asyncGetLinkPreviewDataTask: Task = proc(argEncoded: string) {.gcsafe, nim let parsedWhiteListUrls = parseJson(arg.whiteListedUrls) let parsedWhiteListImgExtensions = arg.whiteListedImgExtensions.split(",") - let httpClient = newHttpClient() for link in arg.links.split(" "): if link == "": @@ -204,13 +203,11 @@ const asyncGetLinkPreviewDataTask: Task = proc(argEncoded: string) {.gcsafe, nim #1. if it's an image, we use httpclient to validate the url if isSupportedImage: - let headResponse = httpclient.head(link) - #validate image url - responseJson["success"] = %(headResponse.code() == Http200 and headResponse.contentType().startsWith("image/")) + #TODO: validate image url using HEAD request responseJson["result"] = %*{ "site": domain, "thumbnailUrl": link, - "contentType": headResponse.contentType() + "contentType": "image/" & path.split(".")[^1] } previewData["links"].add(responseJson) continue