Skip to content

Commit

Permalink
Handle more edge cases in ACL updates (#10279)
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne committed Mar 8, 2023
1 parent 4ee57a3 commit 2b39eac
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/utils/permalinks/Permalinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2b39eac

Please sign in to comment.