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}`);