Escape special HTML characters on the events page

This commit is contained in:
Saivann 2014-02-19 21:43:05 -05:00
parent 701dfd35a2
commit 4bdca82894
3 changed files with 19 additions and 3 deletions

16
_plugins/htmlescape.rb Normal file
View file

@ -0,0 +1,16 @@
#htmlescape espaces special html characters. This is a replacement for
#CGI::escapeHTML, which has an inconsistent behavior with single quotes
#on different ruby versions ( 1.9 and 2.0 ).
#Example:
# {{ page.title | htmlescape }}
module Entities
def htmlescape(input)
input.gsub(/['&\"<>]/, { "'" => '&apos;', '&' => '&amp;', '"' => '&quot;', '<' => '&lt;', '>' => '&gt;' })
end
Liquid::Template.register_filter self
end