This repository has been archived by the owner on Jul 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
adon
committed
Aug 18, 2015
1 parent
8243352
commit fa24fa2
Showing
2 changed files
with
69 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,18 +31,31 @@ Authors: Aditya Mahendrakar <[email protected]> | |
assert.equal(output, '<h1 id="foo" title="asd" checked>hello world 2</h1>'); | ||
}); | ||
|
||
it('should always balance unopened tags', function(){ | ||
it('should balance tags', function(){ | ||
var html = "</div>foo</h2>bar<a href=\"123\">hello<b>world</a><embed>123</embed><br /><br/><p>"; | ||
|
||
// with tag balancing enabled by default | ||
var output = (new Purifier({enableTagBalancing:true})).purify(html); | ||
var output = (new Purifier({tagBalance:{enabled:true}})).purify(html); | ||
assert.equal(output, 'foobar<a href="123">hello<b>world</a><embed />123<br /><br /><p></b>'); | ||
}); | ||
|
||
it('should balance remaining tags and drop inputs when there are too many unclosed tags', function(){ | ||
var html = "<b>1<b>2<b>3<b>4<b>5<b>6</b></b></b></b>"; | ||
|
||
// with tag balancing enabled by default | ||
var output = (new Purifier({tagBalance:{enabled:true, stackSize:3}})).purify(html); | ||
assert.equal(output, '<b>1<b>2<b>3</b></b></b>'); | ||
}); | ||
|
||
it('should not balance tags if disabled', function(){ | ||
var html = "</div>foo</h2>bar<a href=\"123\">hello<b>world</a><embed>123</embed><br /><br/><p>"; | ||
|
||
// with tag balancing disabled | ||
var output = (new Purifier({enableTagBalancing:false})).purify(html); | ||
var output = (new Purifier({tagBalance:{enabled:false}})).purify(html); | ||
assert.equal(output, '</div>foo</h2>bar<a href="123">hello<b>world</a><embed />123</embed><br /><br /><p>'); | ||
}); | ||
|
||
|
||
it('should handle all vectors mentioned in https://html5sec.org', function(){ | ||
var output, i, vector; | ||
for (var i = 0; i < html5secVectors.length; i++) { | ||
|