diff options
Diffstat (limited to 'internal/federation')
-rw-r--r-- | internal/federation/dereferencing/account.go | 21 | ||||
-rw-r--r-- | internal/federation/dereferencing/status.go | 21 |
2 files changed, 34 insertions, 8 deletions
diff --git a/internal/federation/dereferencing/account.go b/internal/federation/dereferencing/account.go index e48507124..65436f9ea 100644 --- a/internal/federation/dereferencing/account.go +++ b/internal/federation/dereferencing/account.go @@ -706,13 +706,26 @@ func (d *Dereferencer) enrichAccount( return nil, nil, gtserror.Newf("empty domain for %s", uri) } - // Ensure the final parsed account URI / URL matches + // Ensure the final parsed account URI or URL matches // the input URI we fetched (or received) it as. - if expect := uri.String(); latestAcc.URI != expect && - latestAcc.URL != expect { + matches, err := util.URIMatches( + uri, + append( + ap.GetURL(apubAcc), // account URL(s) + ap.GetJSONLDId(apubAcc), // account URI + )..., + ) + if err != nil { + return nil, nil, gtserror.Newf( + "error checking dereferenced account uri %s: %w", + latestAcc.URI, err, + ) + } + + if !matches { return nil, nil, gtserror.Newf( "dereferenced account uri %s does not match %s", - latestAcc.URI, expect, + latestAcc.URI, uri.String(), ) } diff --git a/internal/federation/dereferencing/status.go b/internal/federation/dereferencing/status.go index 88746fc3a..fa9906066 100644 --- a/internal/federation/dereferencing/status.go +++ b/internal/federation/dereferencing/status.go @@ -467,13 +467,26 @@ func (d *Dereferencer) enrichStatus( ) } - // Ensure the final parsed status URI / URL matches + // Ensure the final parsed status URI or URL matches // the input URI we fetched (or received) it as. - if expect := uri.String(); latestStatus.URI != expect && - latestStatus.URL != expect { + matches, err := util.URIMatches( + uri, + append( + ap.GetURL(apubStatus), // status URL(s) + ap.GetJSONLDId(apubStatus), // status URI + )..., + ) + if err != nil { + return nil, nil, gtserror.Newf( + "error checking dereferenced status uri %s: %w", + latestStatus.URI, err, + ) + } + + if !matches { return nil, nil, gtserror.Newf( "dereferenced status uri %s does not match %s", - latestStatus.URI, expect, + latestStatus.URI, uri.String(), ) } |