From 2b39eac7b514c8ff02d233b0a6cd90111e8fbcb8 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski Date: Wed, 8 Mar 2023 16:33:58 +0100 Subject: [PATCH] Handle more edge cases in ACL updates (#10279) --- src/utils/permalinks/Permalinks.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/permalinks/Permalinks.ts b/src/utils/permalinks/Permalinks.ts index 9ccb3e2915..b9ee13334c 100644 --- a/src/utils/permalinks/Permalinks.ts +++ b/src/utils/permalinks/Permalinks.ts @@ -219,12 +219,16 @@ export class RoomPermalinkCreator { const getRegex = (hostname: string): RegExp => new RegExp("^" + utils.globToRegexp(hostname, false) + "$"); - const denied = aclEvent.getContent<{ deny: string[] }>().deny || []; - denied.forEach((h) => bannedHostsRegexps.push(getRegex(h))); + const denied = aclEvent.getContent<{ deny: string[] }>().deny; + if (Array.isArray(denied)) { + denied.forEach((h) => bannedHostsRegexps.push(getRegex(h))); + } - const allowed = aclEvent.getContent<{ allow: string[] }>().allow || []; + const allowed = aclEvent.getContent<{ allow: string[] }>().allow; allowedHostsRegexps = []; // we don't want to use the default rule here - allowed.forEach((h) => allowedHostsRegexps.push(getRegex(h))); + if (Array.isArray(denied)) { + allowed.forEach((h) => allowedHostsRegexps.push(getRegex(h))); + } } } this.bannedHostsRegexps = bannedHostsRegexps;