Merge pull request #2244 from jekyll/xml-escape-nil

This commit is contained in:
Parker Moore 2014-04-19 14:18:56 -04:00
commit 702d5520d4
2 changed files with 5 additions and 1 deletions

View File

@ -83,7 +83,7 @@ module Jekyll
#
# Returns the escaped String.
def xml_escape(input)
CGI.escapeHTML(input)
CGI.escapeHTML(input.to_s)
end
# CGI escape a string for use in a URL. Replaces any special characters

View File

@ -93,6 +93,10 @@ class TestFilters < Test::Unit::TestCase
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 "not error when xml escaping nil" do
assert_equal "", @filter.xml_escape(nil)
end
should "escape space as plus" do
assert_equal "my+things", @filter.cgi_escape("my things")
end