Skip to content

Commit

Permalink
Merge pull request #2244 from jekyll/xml-escape-nil
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Apr 19, 2014
2 parents fa9c933 + 1e16ab4 commit 702d552
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jekyll/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def date_to_rfc822(date)
#
# 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
Expand Down
4 changes: 4 additions & 0 deletions test/test_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def initialize(opts = {})
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
Expand Down

0 comments on commit 702d552

Please sign in to comment.