From f12ebcf590c42991176db0ae06892d636b4a78c8 Mon Sep 17 00:00:00 2001 From: Shay Date: Wed, 2 Oct 2024 10:46:56 -0700 Subject: [PATCH] add quote characters (#532) --- src/protections/NsfwProtection.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/protections/NsfwProtection.ts b/src/protections/NsfwProtection.ts index 5269d5e7..8b6f8fd5 100644 --- a/src/protections/NsfwProtection.ts +++ b/src/protections/NsfwProtection.ts @@ -46,8 +46,6 @@ export class NsfwProtection extends Protection { public async handleEvent(mjolnir: Mjolnir, roomId: string, event: any): Promise { if (event['type'] === 'm.room.message') { let content = JSON.stringify(event['content']); - // clean up brackets and "" to simplify regex - content = content.replace(/"|{|}/g, '') if (!content.toLowerCase().includes("mxc")) { return; } @@ -55,7 +53,7 @@ export class NsfwProtection extends Protection { const maybeAlias = await mjolnir.client.getPublishedAlias(roomId) const room = maybeAlias ? maybeAlias : roomId - const mxcs = content.match(/(mxc?:\/\/[^\s]+)/gim); + const mxcs = content.match(/(mxc?:\/\/[^\s'"]+)/gim); if (!mxcs) { //something's gone wrong with the regex await mjolnir.managementRoomOutput.logMessage(LogLevel.ERROR, "NSFWProtection", `Unable to find any mxcs in ${event["event_id"]} in ${room}`);