Handle more edge cases in ACL updates (#10279)

t3chguy/dedup-icons-17oct
Janne Mareike Koschinski 2023-03-08 16:33:58 +01:00 committed by GitHub
parent 4ee57a36e0
commit 2b39eac7b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -219,14 +219,18 @@ export class RoomPermalinkCreator {
const getRegex = (hostname: string): RegExp => const getRegex = (hostname: string): RegExp =>
new RegExp("^" + utils.globToRegexp(hostname, false) + "$"); new RegExp("^" + utils.globToRegexp(hostname, false) + "$");
const denied = aclEvent.getContent<{ deny: string[] }>().deny || []; const denied = aclEvent.getContent<{ deny: string[] }>().deny;
if (Array.isArray(denied)) {
denied.forEach((h) => bannedHostsRegexps.push(getRegex(h))); 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 allowedHostsRegexps = []; // we don't want to use the default rule here
if (Array.isArray(denied)) {
allowed.forEach((h) => allowedHostsRegexps.push(getRegex(h))); allowed.forEach((h) => allowedHostsRegexps.push(getRegex(h)));
} }
} }
}
this.bannedHostsRegexps = bannedHostsRegexps; this.bannedHostsRegexps = bannedHostsRegexps;
this.allowedHostsRegexps = allowedHostsRegexps; this.allowedHostsRegexps = allowedHostsRegexps;
} }