From fc1ad17ba824cfa81b5a4c7247453da74abba718 Mon Sep 17 00:00:00 2001 From: Haileyesus Date: Thu, 12 Feb 2026 19:27:57 +0300 Subject: [PATCH] fix(chat): escape command name in regex to prevent unintended matches --- src/components/chat/hooks/useChatComposerState.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/chat/hooks/useChatComposerState.ts b/src/components/chat/hooks/useChatComposerState.ts index 9b6713c..6220249 100644 --- a/src/components/chat/hooks/useChatComposerState.ts +++ b/src/components/chat/hooks/useChatComposerState.ts @@ -25,6 +25,7 @@ import type { import { useFileMentions } from './useFileMentions'; import { type SlashCommand, useSlashCommands } from './useSlashCommands'; import type { Project, ProjectSession } from '../../../types/app'; +import { escapeRegExp } from '../utils/chatFormatting'; type PendingViewSession = { sessionId: string | null; @@ -273,7 +274,7 @@ export function useChatComposerState({ } try { - const commandMatch = input.match(new RegExp(`${command.name}\\s*(.*)`)); + const commandMatch = input.match(new RegExp(`${escapeRegExp(command.name)}\\s*(.*)`)); const args = commandMatch && commandMatch[1] ? commandMatch[1].trim().split(/\s+/) : [];