Skip to content

Commit

Permalink
Do not process empty abbreviations
Browse files Browse the repository at this point in the history
Fix #6
  • Loading branch information
rlidwka committed Aug 31, 2016
1 parent 7ffc497 commit e75fd25
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.0.4 / 2016-08-31
------------------

- Fixed infinite loop caused by empty abbreviations like `*[]: foo`. Empty abbreviations are no longer parsed.


1.0.3 / 2016-01-05
------------------

Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module.exports = function sub_plugin(md) {

label = state.src.slice(labelStart, labelEnd).replace(/\\(.)/g, '$1');
title = state.src.slice(labelEnd + 2, max).trim();
if (label.length === 0) { return false; }
if (title.length === 0) { return false; }
if (!state.env.abbreviations) { state.env.abbreviations = {}; }
// prepend ':' to avoid conflict with Object.prototype members
Expand Down
37 changes: 37 additions & 0 deletions test/fixtures/abbr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,43 @@ Punctuation as a part of abbr
.


Trailing spaces inside abbreviation
.
*[ test ]: foo bar

test test test
test test test
.
<p>test test test
test <abbr title="foo bar"> test </abbr> test</p>
.


Abbreviation that consists of only spaces
.
*[ ]: foo bar

test test test
test test test
test test test
.
<p>test test test
test test test
test <abbr title="foo bar"> </abbr> test <abbr title="foo bar"> </abbr> test</p>
.


Empty abbreviations should not be processed as such
.
*[]: test

(foo bar)
.
<p>*[]: test</p>
<p>(foo bar)</p>
.


Security 1
.
*[__proto__]: blah
Expand Down

0 comments on commit e75fd25

Please sign in to comment.