Я пытаюсь использовать метод Sanitize из ActionView.
Строка r_str = Helper.instance.sanitize(r_str, :tags => @@allowed_tags, :attributes => @@allowed_attribs)
дает мне ошибку
undefined method `white_list_sanitizer' for Parsers::HTML::Helper:Class
Это мой код в lib/parsers.rb
module Parsers
module HTML
@@allowed_tags = %w(--snip--)
@@allowed_attribs = %w(--snip--)
class Helper
include Singleton
include ActionView::Helpers::SanitizeHelper
end
#Use built-in santizer and the Hpricot plugin
def self.clean(str)
rgx = /<code>(.*?)<\/code>/ #All html within a code tag should be escaped.
r_str = str.gsub(rgx) { |match| "<code>" + CGI.escapeHTML(match[5..-7]) + "</code>" } # TODO: test this.
r_str = Helper.instance.sanitize(r_str, :tags => @@allowed_tags, :attributes => @@allowed_attribs)
Hpricot(r_str)
end
end
--snip--
end
Что я делаю не так?
(Пожалуйста, не комментируйте опасности, связанные с предоставлением пользователем HTML, я знаю о рисках)