mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 03:42:26 -06:00
[bugfix] add stricter checks during all stages of dereferencing remote AS objects (#2639)
* add stricter checks during all stages of dereferencing remote AS objects * a comment
This commit is contained in:
parent
a3aa6042d7
commit
b9013a8ab3
15 changed files with 351 additions and 167 deletions
|
|
@ -64,9 +64,16 @@ func (t *transport) Dereference(ctx context.Context, iri *url.URL) ([]byte, erro
|
|||
}
|
||||
defer rsp.Body.Close()
|
||||
|
||||
// Ensure a non-error status response.
|
||||
if rsp.StatusCode != http.StatusOK {
|
||||
return nil, gtserror.NewFromResponse(rsp)
|
||||
}
|
||||
|
||||
// Ensure that the incoming request content-type is expected.
|
||||
if ct := rsp.Header.Get("Content-Type"); !apiutil.ASContentType(ct) {
|
||||
err := gtserror.Newf("non activity streams response: %s", ct)
|
||||
return nil, gtserror.SetMalformed(err)
|
||||
}
|
||||
|
||||
return io.ReadAll(rsp.Body)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue