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.
|
# Returns the escaped String.
|
||||||
def xml_escape(input)
|
def xml_escape(input)
|
||||||
CGI.escapeHTML(input.to_s)
|
input.to_s.encode(:xml => :attr).gsub(/\A"|"\Z/, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
# CGI escape a string for use in a URL. Replaces any special characters
|
# 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.
|
# Returns a String representation of the object.
|
||||||
def inspect(input)
|
def inspect(input)
|
||||||
CGI.escapeHTML(input.inspect)
|
xml_escape(input.inspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -394,6 +394,10 @@ class TestFilters < JekyllUnitTest
|
||||||
should "return a HTML-escaped string representation of an object" do
|
should "return a HTML-escaped string representation of an object" do
|
||||||
assert_equal "{"<a>"=>1}", @filter.inspect({ "<a>" => 1 })
|
assert_equal "{"<a>"=>1}", @filter.inspect({ "<a>" => 1 })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "quote strings" do
|
||||||
|
assert_equal ""string"", @filter.inspect("string")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "slugify filter" do
|
context "slugify filter" do
|
||||||
|
|
Loading…
Reference in New Issue