-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ok, now #text properly encodes HTML entities to avoid the problem sta…
- Loading branch information
1 parent
71ec78d
commit 36d583f
Showing
7 changed files
with
71 additions
and
20 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
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
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,33 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helper')) | ||
|
||
class TestHelpers < Test::Unit::TestCase | ||
context "#strip_tags" do | ||
context "on safe markup" do | ||
should "strip out tags" do | ||
assert_equal "omgwtfbbq!!1!", Loofah::Helpers.strip_tags("<div>omgwtfbbq</div><span>!!1!</span>") | ||
end | ||
end | ||
|
||
context "on hack attack" do | ||
should "strip escape html entities" do | ||
bad_shit = "<script>alert('evil')</script>" | ||
assert_equal bad_shit, Loofah::Helpers.strip_tags(bad_shit) | ||
end | ||
end | ||
end | ||
|
||
context "#sanitize" do | ||
context "on safe markup" do | ||
should "render the safe html" do | ||
html = "<div>omgwtfbbq</div><span>!!1!</span>" | ||
assert_equal html, Loofah::Helpers.sanitize(html) | ||
end | ||
end | ||
|
||
context "on hack attack" do | ||
should "strip the unsafe tags" do | ||
assert_equal "alert('evil')<span>w00t</span>", Loofah::Helpers.sanitize("<script>alert('evil')</script><span>w00t</span>") | ||
end | ||
end | ||
end | ||
end |
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