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("