mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-13 13:37:31 -07:00
URL parsing check to prevent delivery crashes
This commit is contained in:
parent
3fbc5c5a7d
commit
37c4ef56d7
1 changed files with 18 additions and 6 deletions
|
@ -1,8 +1,9 @@
|
||||||
import { IsNull, Not } from "typeorm";
|
import {IsNull, Not} from "typeorm";
|
||||||
import { Users, Followings } from "@/models/index.js";
|
import {Followings, Users} from "@/models/index.js";
|
||||||
import type { ILocalUser, IRemoteUser, User } from "@/models/entities/user.js";
|
import type {ILocalUser, IRemoteUser, User} from "@/models/entities/user.js";
|
||||||
import { deliver } from "@/queue/index.js";
|
import {deliver} from "@/queue/index.js";
|
||||||
import { skippedInstances } from "@/misc/skipped-instances.js";
|
import {skippedInstances} from "@/misc/skipped-instances.js";
|
||||||
|
import {apLogger} from "@/remote/activitypub/logger";
|
||||||
|
|
||||||
//#region types
|
//#region types
|
||||||
interface IRecipe {
|
interface IRecipe {
|
||||||
|
@ -132,7 +133,18 @@ export default class DeliverManager {
|
||||||
// deliver
|
// deliver
|
||||||
for (const inbox of inboxes) {
|
for (const inbox of inboxes) {
|
||||||
// skip instances as indicated
|
// skip instances as indicated
|
||||||
if (instancesToSkip.includes(new URL(inbox).host)) continue;
|
|
||||||
|
try {
|
||||||
|
const host = new URL(inbox).host;
|
||||||
|
if (instancesToSkip.includes(host))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
// skip invalid URLs
|
||||||
|
apLogger.error(`Invalid inbox URL: ${inbox}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
deliver(this.actor, this.activity, inbox);
|
deliver(this.actor, this.activity, inbox);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue