Skip to content

Commit

Permalink
Merge pull request #2789 from GetStream/fix/regex-max-stack-depth-crash
Browse files Browse the repository at this point in the history
fix: regex max stack depth crash
  • Loading branch information
isekovanic authored Nov 18, 2024
2 parents e029830 + e847dca commit 32115ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,12 @@ exports[`Thread should match thread snapshot 1`] = `
}
>
<Text
numberOfLines={5}
style={
{
"alignItems": "flex-start",
"flexDirection": "row",
"flexWrap": "wrap",
"justifyContent": "flex-start",
"marginBottom": 8,
"marginTop": 8,
}
Expand Down Expand Up @@ -823,9 +826,12 @@ exports[`Thread should match thread snapshot 1`] = `
}
>
<Text
numberOfLines={5}
style={
{
"alignItems": "flex-start",
"flexDirection": "row",
"flexWrap": "wrap",
"justifyContent": "flex-start",
"marginBottom": 8,
"marginTop": 8,
}
Expand Down Expand Up @@ -1171,9 +1177,12 @@ exports[`Thread should match thread snapshot 1`] = `
}
>
<Text
numberOfLines={5}
style={
{
"alignItems": "flex-start",
"flexDirection": "row",
"flexWrap": "wrap",
"justifyContent": "flex-start",
"marginBottom": 8,
"marginTop": 8,
}
Expand Down Expand Up @@ -1553,9 +1562,12 @@ exports[`Thread should match thread snapshot 1`] = `
}
>
<Text
numberOfLines={5}
style={
{
"alignItems": "flex-start",
"flexDirection": "row",
"flexWrap": "wrap",
"justifyContent": "flex-start",
"marginBottom": 8,
"marginTop": 8,
}
Expand Down

0 comments on commit 32115ca

Please sign in to comment.