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
Showing
2 changed files
with
76 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
function sanitize(html, options) { | ||
return Element("div").update(html).sanitizeContents(options).innerHTML; | ||
} | ||
|
||
new Test.Unit.Runner({ | ||
testSanitize: function() { | ||
var runner = this; | ||
|
||
runner.assertEqual( | ||
"Hello", | ||
sanitize("Hello", {}) | ||
); | ||
|
||
runner.assertEqual( | ||
"Hello", | ||
sanitize("<strong>Hello</strong>", {}) | ||
); | ||
|
||
runner.assertEqual( | ||
"Hello", | ||
sanitize("<em><strong>Hello</strong></em>", {}) | ||
); | ||
|
||
runner.assertEqual( | ||
"<strong>Hello</strong>", | ||
sanitize("<strong>Hello</strong>", {allow: "strong"}) | ||
); | ||
|
||
runner.assertEqual( | ||
"<strong>Hello</strong>", | ||
sanitize("<em><strong>Hello</strong></em>", {allow: "strong"}) | ||
); | ||
|
||
runner.assertEqual( | ||
"<strong>Hello</strong>", | ||
sanitize("<strong><em>Hello</em></strong>", {allow: "strong"}) | ||
); | ||
|
||
runner.assertEqual( | ||
"<strong>Hello</strong> World!", | ||
sanitize("<p><strong><em>Hello</em></strong> World!</p>", {allow: "strong"}) | ||
); | ||
|
||
runner.assertEqual( | ||
"<strong><em>Hello</em></strong>", | ||
sanitize("<strong><em>Hello</em></strong>", {allow: "em, strong"}) | ||
); | ||
|
||
runner.assertEqual( | ||
"<a>Google</a>", | ||
sanitize("<a href='http://www.google.com/' title=\"Google\">Google</a>", {allow: "a"}) | ||
); | ||
|
||
runner.assertEqual( | ||
"<a href=\"http://www.google.com/\">Google</a>", | ||
sanitize("<a href=\"http://www.google.com/\" title=\"Google\">Google</a>", {allow: "a[href]"}) | ||
); | ||
|
||
if (Prototype.Browser.IE) { | ||
runner.assertEqual( | ||
"Hello<span id=bookmark> </span>", | ||
sanitize("Hello<span id=bookmark> </span>", {allow: "span[id]"}) | ||
); | ||
} else { | ||
runner.assertEqual( | ||
"Hello<span id=\"bookmark\"> </span>", | ||
sanitize("Hello<span id=\"bookmark\"> </span>", {allow: "span[id]"}) | ||
); | ||
} | ||
|
||
runner.assertEqual( | ||
"<img src=\"http://www.google.com/intl/en_ALL/images/logo.gif\">", | ||
sanitize("<img src=\"http://www.google.com/intl/en_ALL/images/logo.gif\">", {allow: "img[src], a[href]"}) | ||
); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.