[bugfix] return 400 Bad Request on more cases of malformed AS data (#2399)

This commit is contained in:
kim
2023-11-30 16:22:34 +00:00
committed by GitHub
parent 5fd2e427bb
commit eb170003b8
47 changed files with 1493 additions and 1013 deletions

View File

@@ -47,7 +47,7 @@ func (p *Processor) EmailTest(ctx context.Context, account *gtsmodel.Account, to
}
if err := p.emailSender.SendTestEmail(toAddress, testData); err != nil {
if errorType := gtserror.Type(err); errorType == gtserror.TypeSMTP {
if gtserror.IsSMTP(err) {
// An error occurred during the SMTP part.
// We should indicate this to the caller, as
// it will likely help them debug the issue.

View File

@@ -382,7 +382,7 @@ func (p *Processor) accountsByNamestring(
if err != nil {
// Check for semi-expected error types.
// On one of these, we can continue.
if !gtserror.Unretrievable(err) && !gtserror.WrongType(err) {
if !gtserror.IsUnretrievable(err) && !gtserror.IsWrongType(err) {
err = gtserror.Newf("error looking up @%s@%s as account: %w", username, domain, err)
return gtserror.NewErrorInternalError(err)
}
@@ -491,7 +491,7 @@ func (p *Processor) byURI(
if err != nil {
// Check for semi-expected error types.
// On one of these, we can continue.
if !gtserror.Unretrievable(err) && !gtserror.WrongType(err) {
if !gtserror.IsUnretrievable(err) && !gtserror.IsWrongType(err) {
err = gtserror.Newf("error looking up %s as account: %w", uri, err)
return gtserror.NewErrorInternalError(err)
}
@@ -509,7 +509,7 @@ func (p *Processor) byURI(
if err != nil {
// Check for semi-expected error types.
// On one of these, we can continue.
if !gtserror.Unretrievable(err) && !gtserror.WrongType(err) {
if !gtserror.IsUnretrievable(err) && !gtserror.IsWrongType(err) {
err = gtserror.Newf("error looking up %s as status: %w", uri, err)
return gtserror.NewErrorInternalError(err)
}

View File

@@ -92,7 +92,7 @@ func (p *Processor) Lookup(
false, // never resolve!
)
if err != nil {
if gtserror.Unretrievable(err) {
if gtserror.IsUnretrievable(err) {
// ErrNotRetrievable is fine, just wrap it in
// a 404 to indicate we couldn't find anything.
err := fmt.Errorf("%s not found", query)