require "test/unit" require "nitro/html" include N class TC_HtmlUtils < Test::Unit::TestCase # :nodoc: all def test_escape assert_equal("<b>test</b>", HtmlUtils::escape("test")) assert_equal("<p>test", HtmlUtils::escape("

test")) assert_equal("", HtmlUtils::escape("")) assert_equal(nil, HtmlUtils::escape(nil)) end def test_expand_urls s = "visit http://www.navel.gr" r = "visit http://www.navel.gr" assert_equal(r, HtmlUtils::expand_urls(s)) s = "visit www.navel.gr" r = "visit http://www.navel.gr" assert_equal(r, HtmlUtils::expand_urls(s)) assert_equal(nil, HtmlUtils::expand_urls(nil)) s = "visit: www.navel.gr" r = "visit: http://www.navel.gr" assert_equal(r, HtmlUtils::expand_urls(s)) end def test_only_safe_tags s = "lala
" r = "<table>lala</table>" assert_equal(r, HtmlUtils::only_safe_tags(s)) # bug: img is NOT A SAFE tag, fucks up layout s = "" # lala is quoted because it belongs in an open tag! r = "<img src='koko'><table>" assert_equal(r, HtmlUtils::only_safe_tags(s)) s = "
" # lala is not quoted because it belongs in a valid tag! r = "<img src='koko'><table>" assert_equal(r, HtmlUtils::only_safe_tags(s)) s = "