Added cgi_escape filter

This commit is contained in:
Martin Vilcans 2009-05-02 00:44:33 +02:00
parent 445347e259
commit 6968346703
2 changed files with 12 additions and 0 deletions

View File

@ -21,6 +21,10 @@ module Jekyll
input.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;")
end
def cgi_escape(input)
CGI::escape(input)
end
def number_of_words(input)
input.split.length
end

View File

@ -37,5 +37,13 @@ class TestFilters < Test::Unit::TestCase
assert_equal "AT&amp;T", @filter.xml_escape("AT&T")
assert_equal "&lt;code&gt;command &amp;lt;filename&amp;gt;&lt;/code&gt;", @filter.xml_escape("<code>command &lt;filename&gt;</code>")
end
should "escape space as plus" do
assert_equal "my+things", @filter.cgi_escape("my things")
end
should "escape special characters" do
assert_equal "hey%21", @filter.cgi_escape("hey!")
end
end
end