MessageLinkEmbeds: limit embed count to prevent DoS

This commit is contained in:
Vendicated 2026-09-14 22:29:33 +02:00
parent 339b85ba40
commit 0016b9b7ff
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -236,11 +236,16 @@ function MessageEmbedAccessory({ message }: { message: Message; }) {
const accessories = [] as (JSX.Element | null)[];
const seen = new Set<string>();
let count = 0;
for (const [_, channelId, messageId] of message.content!.matchAll(messageLinkRegex)) {
if (embeddedBy.includes(messageId) || embeddedBy.length > 2) {
if (embeddedBy.includes(messageId) || embeddedBy.length > 2 || seen.has(messageId) || count >= 5) {
continue;
}
seen.add(messageId);
count++;
const linkedChannel = ChannelStore.getChannel(channelId);
if (!linkedChannel || (!linkedChannel.isPrivate() && !PermissionStore.can(PermissionsBits.VIEW_CHANNEL, linkedChannel))) {
continue;