Added cgi_escape filter
This commit is contained in:
parent
445347e259
commit
6968346703
|
@ -21,6 +21,10 @@ module Jekyll
|
||||||
input.gsub("&", "&").gsub("<", "<").gsub(">", ">")
|
input.gsub("&", "&").gsub("<", "<").gsub(">", ">")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cgi_escape(input)
|
||||||
|
CGI::escape(input)
|
||||||
|
end
|
||||||
|
|
||||||
def number_of_words(input)
|
def number_of_words(input)
|
||||||
input.split.length
|
input.split.length
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,5 +37,13 @@ class TestFilters < Test::Unit::TestCase
|
||||||
assert_equal "AT&T", @filter.xml_escape("AT&T")
|
assert_equal "AT&T", @filter.xml_escape("AT&T")
|
||||||
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></code>")
|
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></code>")
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue