Skip to content

Commit

Permalink
Merge pull request #5016 from aloisklink/fix/4964-fix-invalid-ellipse…
Browse files Browse the repository at this point in the history
…Text-regex

fix(flow): fix invalid ellipseText regex
  • Loading branch information
knsv committed Nov 6, 2023
2 parents f5bd1e0 + 172d90e commit 7c7f3dd
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 7c7f3dd

Please sign in to comment.