Skip to content

Commit

Permalink
26 aliases with trailing comma cause infinite loop (#33)
Browse files Browse the repository at this point in the history
* fix: Aliases with trailing comma cause infinite loop and out of memory failure (#26)

Closes #26
  • Loading branch information
about-code authored Sep 26, 2019
1 parent 369f73f commit d5ddd5b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/terminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ function getTermVisitor(context, glossary) {
.replace(/\s?\S?--\>/gs, "")
.replace(/\b(.*)\b/gs, "$1")
.split(/\s?,\s?/)
.filter(alias => alias !== "")
);
}
State.next(State.AWAIT_DEFINITION);
Expand Down
7 changes: 7 additions & 0 deletions test/input/features/aliases_and_synonyms/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ T4.Alias3
WHEN there is an HTML-multi-line-comment beginning with 'Aliases:' and an empty
line THEN the subsequent comma-separated lines of words MUST be detected as the
term's aliases.

## Term 5
<!-- Aliases: T5-Alias1, T5-Alias2, -->
GIVEN there is an HTML-single-line-comment beginning with 'Aliases:'
AND the comment ends with a trailing comma
THEN this MUST NOT result in an infinite loop or out-of-memory error
as has been reported in #26
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ T4.Alias3
WHEN there is an HTML-multi-line-comment beginning with 'Aliases:' and an empty
line THEN the subsequent comma-separated lines of words MUST be detected as the
term's aliases.

## [Term 5](#term-5)

<!-- Aliases: T5-Alias1, T5-Alias2, -->

GIVEN there is an HTML-single-line-comment beginning with 'Aliases:'
AND the comment ends with a trailing comma
THEN this MUST NOT result in an infinite loop or out-of-memory error
as has been reported in #26
19 changes: 19 additions & 0 deletions test/output-expected/terms.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,25 @@
],
"ignoreCase": false
},
{
"shortDesc": "",
"term": "Term 5",
"hint": "",
"longDesc": "GIVEN there is an HTML-single-line-comment beginning with 'Aliases:'\nAND the comment ends with a trailing comma\nTHEN this MUST NOT result in an infinite loop or out-of-memory error\nas has been reported in #26",
"anchor": "#term-5",
"glossary": {
"file": "./features/aliases_and_synonyms/glossary.md",
"termHint": "",
"basePath": "/{redacted}/input/features/aliases_and_synonyms/glossary.md",
"outPath": "/{redacted}/output-actual/features/aliases_and_synonyms/glossary.md"
},
"regex": {},
"aliases": [
"T5-Alias1",
"T5-Alias2"
],
"ignoreCase": false
},
{
"shortDesc": "",
"term": "Term contains äöüß Umlauts",
Expand Down

0 comments on commit d5ddd5b

Please sign in to comment.