[bugfix] Fix NegotiateFormat with multiple accept headers (#1797)

* [bugfix] Fix NegotiateAccept with multi accept

There's a bug in Gin's NegotiateFormat that doesn't handle the presence
of multilpe accept headers. This lifts the code from the PR @tsmethurst
sent a year ago to Gin into our codebase to fix the issue.

* [bugfix] Concat accept header in webfinger

Some implementations bug out when there's multiple accept headers,
including Gin (see 7050112af1). But things
seem to work reliably with a single accept header with multiple parts.

Fixes: #1793
This commit is contained in:
Daenney
2023-05-16 15:08:45 +02:00
committed by GitHub
parent 2478d83c84
commit e91cabb704
5 changed files with 127 additions and 5 deletions

View File

@@ -90,7 +90,7 @@ func (m *Module) threadGETHandler(c *gin.Context) {
// if we're getting an AP request on this endpoint we
// should render the status's AP representation instead
accept := c.NegotiateFormat(string(apiutil.TextHTML), string(apiutil.AppActivityJSON), string(apiutil.AppActivityLDJSON))
accept := apiutil.NegotiateFormat(c, string(apiutil.TextHTML), string(apiutil.AppActivityJSON), string(apiutil.AppActivityLDJSON))
if accept == string(apiutil.AppActivityJSON) || accept == string(apiutil.AppActivityLDJSON) {
m.returnAPStatus(ctx, c, username, statusID, accept)
return