From 4ea3f370245f1d87e9b5fd4c2a2b56e25817b44f Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sat, 3 Feb 2024 14:42:36 +0000 Subject: [PATCH] Ignore invalid MXIDs in permissions command --- src/commands/PermissionsCommand.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/commands/PermissionsCommand.ts b/src/commands/PermissionsCommand.ts index acce283..d7c5316 100644 --- a/src/commands/PermissionsCommand.ts +++ b/src/commands/PermissionsCommand.ts @@ -15,7 +15,7 @@ limitations under the License. */ import { ICommand } from "./ICommand"; -import { MatrixClient } from "matrix-bot-sdk"; +import { LogService, MatrixClient } from "matrix-bot-sdk"; import { Conference } from "../Conference"; import { ResolvedPersonIdentifier } from "../invites"; import { runRoleCommand } from "./actions/roles"; @@ -49,6 +49,12 @@ export class PermissionsCommand implements ICommand { for (const person of people) { if (!person.mxid) continue; + + if (! /^@[^:]+:[^\.]+\..+$/.test(person.mxid)) { + LogService.warn("PermissionsCommand", `ignoring invalid MXID ${person.mxid}`); + continue; + } + if (powerLevels['users'][person.mxid]) continue; powerLevels['users'][person.mxid] = 50; }