Merge pull request #4694 from pathawks/pr/xml_escape
Merge pull request 4694
This commit is contained in:
commit
e873934d60
|
@ -117,7 +117,7 @@ module Jekyll
|
|||
#
|
||||
# Returns the escaped String.
|
||||
def xml_escape(input)
|
||||
CGI.escapeHTML(input.to_s)
|
||||
input.to_s.encode(:xml => :attr).gsub(/\A"|"\Z/, "")
|
||||
end
|
||||
|
||||
# CGI escape a string for use in a URL. Replaces any special characters
|
||||
|
@ -308,7 +308,7 @@ module Jekyll
|
|||
#
|
||||
# Returns a String representation of the object.
|
||||
def inspect(input)
|
||||
CGI.escapeHTML(input.inspect)
|
||||
xml_escape(input.inspect)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -394,6 +394,10 @@ class TestFilters < JekyllUnitTest
|
|||
should "return a HTML-escaped string representation of an object" do
|
||||
assert_equal "{"<a>"=>1}", @filter.inspect({ "<a>" => 1 })
|
||||
end
|
||||
|
||||
should "quote strings" do
|
||||
assert_equal ""string"", @filter.inspect("string")
|
||||
end
|
||||
end
|
||||
|
||||
context "slugify filter" do
|
||||
|
|
Loading…
Reference in New Issue