From b93f76b15751cc2b4f1e5eed5fa520d52cb62e9a Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sat, 3 Aug 2024 09:22:44 -0400 Subject: [PATCH] Adding back in doctype check. --- crates/api_common/src/request.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index 01927d5d9..b69cd036c 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -184,6 +184,18 @@ pub async fn generate_post_link_metadata( fn extract_opengraph_data(html_bytes: &[u8], url: &Url) -> LemmyResult { let html = String::from_utf8_lossy(html_bytes); + // Make sure the first line is doctype html + let first_line = html + .trim_start() + .lines() + .next() + .ok_or(LemmyErrorType::NoLinesInHtml)? + .to_lowercase(); + + if !first_line.starts_with("