Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"js-cookie": "3.0.5",
"js-yaml": "4.1.1",
"jsonwebtoken": "catalog:",
"linkify-it": "5.0.0",
"linkify-it": "5.0.1",
"lucide-react": "0.552.0",
"mailgun.js": "12.7.1",
"monaco-editor": "0.55.1",
Expand Down
12 changes: 10 additions & 2 deletions apps/web/src/components/cloud-agent-next/MessageBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ import LinkifyIt from 'linkify-it';

const linkify = new LinkifyIt();

// Cap input length before passing to linkify to prevent O(N²) scan-loop DoS
// (CVE-2026-48801) in case the patched library is ever rolled back.
const MAX_LINKIFY_LENGTH = 50_000;

function TextWithLinks({ text }: { text: string }) {
const parts: React.ReactNode[] = [];
let lastIndex = 0;
for (const match of linkify.match(text) ?? []) {
const safeText = text.length > MAX_LINKIFY_LENGTH ? '' : text;
for (const match of linkify.match(safeText) ?? []) {
if (match.index > lastIndex) {
parts.push(text.slice(lastIndex, match.index));
}
Expand All @@ -46,7 +51,10 @@ function TextWithLinks({ text }: { text: string }) {
);
lastIndex = match.lastIndex;
}
if (lastIndex < text.length) {
// When safeText === '' (text exceeded limit), show the full original text unlinked.
if (safeText.length < text.length) {
parts.push(text);
} else if (lastIndex < text.length) {
parts.push(text.slice(lastIndex));
}
return <>{parts}</>;
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.