deliver-delayed で URL のパースに失敗した際に全てがコケる問題を修正 (#164)

* deliver-delayed で URL のパースに失敗した際に全てがコケる問題を修正

* validateActor に inbox / sharedInbox のバリデーションを追加

* fix quote

* 念のため inbox-delayed も
This commit is contained in:
riku6460 2023-09-12 02:56:51 +09:00 committed by kakkokari-gtyih
parent 1144fbc892
commit 9c0fcf0e06
1 changed files with 15 additions and 0 deletions

View File

@ -156,6 +156,21 @@ export class ApPersonService implements OnModuleInit {
throw new Error('invalid Actor: wrong inbox');
}
try {
new URL(x.inbox);
} catch {
throw new Error('invalid Actor: wrong inbox');
}
const sharedInbox = x.sharedInbox ?? x.endpoints?.sharedInbox;
if (typeof sharedInbox === 'string') {
try {
new URL(sharedInbox);
} catch {
throw new Error('invalid Actor: wrong sharedInbox');
}
}
if (!(typeof x.preferredUsername === 'string' && x.preferredUsername.length > 0 && x.preferredUsername.length <= 128 && /^\w([\w-.]*\w)?$/.test(x.preferredUsername))) {
throw new Error('invalid Actor: wrong username');
}