Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes catastrophic backtracking for long strings of spaces #629

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
23 changes: 23 additions & 0 deletions index.compiler.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4824,3 +4824,26 @@ it('#597 handles script tag with empty content', () => {
</script>
`)
})

it('#473 handles content with multiple empty spaces without crashing', () => {
render(
compiler(
'Test \r\n \r\n Test'
)
)

expect(root.innerHTML).toMatchInlineSnapshot(`
<div>
<p>
Test
</p>
<pre>
<code>
</code>
</pre>
<p>
Test
</p>
</div>
`)
})
2 changes: 1 addition & 1 deletion index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const BREAK_LINE_R = /^ {2,}\n/
const BREAK_THEMATIC_R = /^(?:( *[-*_])){3,} *(?:\n *)+\n/
const CODE_BLOCK_FENCED_R =
/^(?: {1,3})?(`{3,}|~{3,}) *(\S+)? *([^\n]*?)?\n([\s\S]*?)(?:\1\n?|$)/
const CODE_BLOCK_R = /^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/
const CODE_BLOCK_R = /^(?: {4}[^\n]+\n*)+(?:\n *)*\n?/
const CODE_INLINE_R = /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/
const CONSECUTIVE_NEWLINE_R = /^(?:\n *)*\n/
const CR_NEWLINE_R = /\r\n?/g
Expand Down
Loading