[backend/core] Fix profile field verification for MFM link node fields

This commit is contained in:
Laura Hausmann 2025-02-22 23:32:08 +01:00
parent 9d480e3fba
commit 5bf14a6a06
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -1183,9 +1183,17 @@ public class UserService(
foreach (var userProfileField in user.UserProfile!.Fields) foreach (var userProfileField in user.UserProfile!.Fields)
{ {
var url = userProfileField.Value;
if (url.StartsWith('[') && url.EndsWith(')'))
{
var idx = url.IndexOf("](", StringComparison.Ordinal);
if (idx != -1 && url.Length >= idx + "https://".Length)
url = url[(idx + 2)..^1];
}
if ( if (
!userProfileField.Value.StartsWith("https://") !url.StartsWith("https://")
|| !Uri.TryCreate(userProfileField.Value, UriKind.Absolute, out var uri) || !Uri.TryCreate(url, UriKind.Absolute, out var uri)
|| uri is not { Scheme: "https" } || uri is not { Scheme: "https" }
) )
{ {