From ecfea10e359b9c9e7c0e6b5fd092e3caa5587df6 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:11:07 +0200 Subject: [bugfix] Use punycode for `host` part of `resource` query param when doing webfinger requests (#3133) * [bugfix] use punycode when webfingering * account for punycode when checking if final URI matches expected * hmm * fix test --- internal/federation/dereferencing/account.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'internal/federation/dereferencing/account.go') 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(), ) } -- cgit v1.2.3