[backend/core] Verify links that have a matching link element in their document head

This commit is contained in:
pancakes 2025-02-21 13:28:35 +10:00
parent da2cb76aab
commit 04a5512c61
No known key found for this signature in database
GPG key ID: ED53D426432B861B

View file

@ -1215,11 +1215,14 @@ public class UserService(
var html = await res.Content.ReadAsStringAsync();
var document = await new HtmlParser().ParseDocumentAsync(html);
var headLinks = document.Head?.Children.Where(el => el.NodeName.ToLower() == "link").ToList() ?? [];
userProfileField.IsVerified =
document.Links.Any(a => (a.GetAttribute("rel")?.Contains("me")
?? false)
&& a.GetAttribute("href") == profileUrl
|| a.GetAttribute("href") == user.GetUriOrPublicUri(instance.Value));
headLinks.Concat(document.Links)
.Any(a => (a.GetAttribute("rel")?.Contains("me")
?? false)
&& a.GetAttribute("href") == profileUrl
|| a.GetAttribute("href") == user.GetUriOrPublicUri(instance.Value));
}
catch (Exception e)
{