Skip to content

Commit

Permalink
Fixed parser bug with invalid nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
samclarke committed Dec 5, 2016
1 parent 40def1e commit bb52553
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Version 1.5.2:
Fixed BBCode parser bug that can cause content to be lost under certain
types of invalid nesting.
- Thanks to Jones for reporting.

Version 1.5.1:
Fixed bug with event handlers throwing an error.
- Thanks to @agungsijawir for reporting
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/bbcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@
// previously cloned tags as it's children
clone = curTok.clone();

if (cloned.length > 1) {
if (cloned.length) {
clone.children.push(last(cloned));
}

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/plugins/bbcode.parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ define([
'[color][b][s][i]test[/i][/s][/b][/color]',
'Closing parent tag from deeply nested child tag'
);

assert.equal(
this.parser.toBBCode('[left][list][*]xyz[/left][list][*]abc[/list]'),
'[left][list]\n[*]xyz[/*]\n[/list]\n[/left]\n[list]\n[*][list]\n' +
'[*]abc[/*]\n[/list]\n[/*]\n[/list]\n',
'Closing parent tag from list item'
);
});


Expand Down

0 comments on commit bb52553

Please sign in to comment.