Skip to content

Commit

Permalink
fix(flow): fix invalid ellipseText regex
Browse files Browse the repository at this point in the history
This invalid regex was causing Mermaid to freeze.
  • Loading branch information
aloisklink committed Nov 6, 2023
1 parent 29942c0 commit 172d90e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ describe('[Text] when parsing', () => {
expect(vert['A'].text).toBe('this is an ellipse');
});

it('should not freeze when ellipse text has a `(`', function () {
expect(() => flow.parser.parse('graph\nX(- My Text (')).toThrowError();
});

it('should handle text in diamond vertices with space', function () {
const res = flow.parser.parse('graph TD;A(chimpansen hoppar)-->C;');

Expand Down
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/flowchart/parser/flow.jison
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ that id.
<*>\s*\~\~[\~]+\s* return 'LINK';

<ellipseText>[-/\)][\)] { this.popState(); return '-)'; }
<ellipseText>[^\(\)\[\]\{\}]|-/!\)+ return "TEXT"
<ellipseText>[^\(\)\[\]\{\}]|-\!\)+ return "TEXT"
<*>"(-" { this.pushState("ellipseText"); return '(-'; }

<text>"])" { this.popState(); return 'STADIUMEND'; }
Expand Down

0 comments on commit 172d90e

Please sign in to comment.