Skip to content

Commit ded4282

Browse files
authored
fix(web): strip HTML tags iteratively in MCP tool metadata sanitizer (#1273)
1 parent 8adae63 commit ded4282

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

packages/web/src/ee/features/chat/mcp/mcpToolMetadata.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ function removeControlCharacters(value: string): string {
4040
}
4141

4242
function removeHtmlTags(value: string): string {
43-
return value.replace(/<[^>]*>/g, '');
43+
// Strip repeatedly until stable: a single pass can reintroduce a tag
44+
// sequence (e.g. "<scr<x>ipt>" collapses to "<script>"), so loop until
45+
// no more tags are removed.
46+
let current = value;
47+
let previous: string;
48+
do {
49+
previous = current;
50+
current = current.replace(/<[^>]*>/g, '');
51+
} while (current !== previous);
52+
return current;
4453
}
4554

4655
function normalizeWhitespace(value: string): string {

0 commit comments

Comments
 (0)