Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Handle more edge cases in ACL updates
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne committed Mar 7, 2023
1 parent af1ec76 commit 7bef69e
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 7bef69e

Please sign in to comment.