fix(MessageMentions): infinite loop in parsedUsers getter (#8430)

This commit is contained in:
Almeida
2022-08-08 10:10:32 +01:00
committed by GitHub
parent 5b053cf82e
commit b8a31360a2
2 changed files with 11 additions and 2 deletions

View File

@@ -48,6 +48,14 @@ class MessageMentions {
*/
static GlobalChannelsPattern = new RegExp(this.ChannelsPattern.source, 'g');
/**
* A global regular expression variant of {@link MessageMentions.UsersPattern}.
* @type {RegExp}
* @memberof MessageMentions
* @private
*/
static GlobalUsersPattern = new RegExp(this.UsersPattern.source, 'g');
constructor(message, users, roles, everyone, crosspostedChannels, repliedUser) {
/**
* The client the message is from
@@ -225,7 +233,7 @@ class MessageMentions {
if (this._parsedUsers) return this._parsedUsers;
this._parsedUsers = new Collection();
let matches;
while ((matches = this.constructor.UsersPattern.exec(this._content)) !== null) {
while ((matches = this.constructor.GlobalUsersPattern.exec(this._content)) !== null) {
const user = this.client.users.cache.get(matches[1]);
if (user) this._parsedUsers.set(user.id, user);
}

View File

@@ -1881,8 +1881,9 @@ export class MessageMentions {
public crosspostedChannels: Collection<Snowflake, CrosspostedChannel>;
public toJSON(): unknown;
public static ChannelsPattern: typeof FormattingPatterns.Channel;
private static GlobalChannelsPattern: RegExp;
private static GlobalUsersPattern: RegExp;
public static ChannelsPattern: typeof FormattingPatterns.Channel;
public static EveryonePattern: RegExp;
public static RolesPattern: typeof FormattingPatterns.Role;
public static UsersPattern: typeof FormattingPatterns.User;