Skip to content

Commit

Permalink
chore: do not parse if text.length is more than 4000 (#542)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomek Zawadzki <[email protected]>
  • Loading branch information
dominictb and tomekzaw authored Nov 13, 2024
1 parent 4a62d9b commit 3ce45a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import ExpensiMark from 'expensify-common/dist/ExpensiMark';
import {unescapeText} from './utils';

const MAX_PARSABLE_LENGTH = 4000;

type MarkdownType =
| 'bold'
| 'italic'
Expand Down Expand Up @@ -272,6 +274,9 @@ function groupRanges(ranges: MarkdownRange[]) {
}

function parseExpensiMarkToRanges(markdown: string): MarkdownRange[] {
if (markdown.length > MAX_PARSABLE_LENGTH) {
return [];
}
try {
const html = parseMarkdownToHTML(markdown);
const tokens = parseHTMLToTokens(html);
Expand Down
18 changes: 9 additions & 9 deletions parser/react-native-live-markdown-parser.js

Large diffs are not rendered by default.

0 comments on commit 3ce45a2

Please sign in to comment.