Skip to content

Commit

Permalink
fix: regex state machine stack depth crash
Browse files Browse the repository at this point in the history
  • Loading branch information
isekovanic committed Nov 18, 2024
1 parent e029830 commit 99abac0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ const ChannelWithContext = <
MessageStatus = MessageStatusDefault,
MessageSystem = MessageSystemDefault,
MessageText,
messageTextNumberOfLines = 5,
messageTextNumberOfLines,
MessageTimestamp = MessageTimestampDefault,
MessageUserReactions = MessageUserReactionsDefault,
MessageUserReactionsAvatar = MessageUserReactionsAvatarDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ export const generateMarkdownText = (text?: string) => {

resultText = resultText.replace(/[<"'>]/g, '\\$&');

// Remove whitespaces that come directly after newlines except in code blocks where we deem this allowed.
resultText = resultText.replace(/(```[\s\S]*?```|`.*?`)|\n[ ]{2,}/g, (_, code) => {
if (code) return code;
return '\n';
});

return resultText;
};

0 comments on commit 99abac0

Please sign in to comment.