Skip to content

Commit 115b4fc

Browse files
committed
chore: Escape prefix in RegEx
1 parent ed24627 commit 115b4fc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/ps/handlers/commands/spoof.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type Client, Message, type Room } from 'ps-client';
33
import { PSGames } from '@/cache';
44
import { prefix } from '@/config/ps';
55
import { ChatError } from '@/utils/chatError';
6+
import { escapeRegEx } from '@/utils/regexEscape';
67
import { toId } from '@/utils/toId';
78

89
import type { TranslationFn } from '@/i18n/types';
@@ -28,7 +29,7 @@ export function spoof(argData: string, message: PSMessage, $T: TranslationFn): P
2829
if (!room) throw new ChatError($T('INVALID_ROOM_ID'));
2930
const by = room.users.find(user => toId(user) === message.author.id);
3031
if (!by) throw new ChatError($T('NOT_IN_ROOM'));
31-
const [empty, _type, _from, rest] = message.raw.replace(new RegExp(`${prefix}@\\S* `), prefix).lazySplit('|', 3);
32+
const [empty, _type, _from, rest] = message.raw.replace(new RegExp(`${escapeRegEx(prefix)}@\\S* `), prefix).lazySplit('|', 3);
3233
return new Message({
3334
type: 'chat',
3435
raw: [empty, 'spoof', by, rest].join('|'),

0 commit comments

Comments
 (0)