1

嘿,我正在尝试找到一种方法来限制用户使用某些标签,例如h1.h2.在表单字段中。就像我不希望他们能够炸毁表单域和垃圾邮件。

有没有办法做到这一点,还是我必须在 gem 库中更改它?

4

1 回答 1

2

查看这篇关于如何允许某些标签的帖子:http: //jeff.jones.be/technology/articles/textile-filtering-with-redcloth/

配置/初始化程序/redcloth_extension.rb

module RedCloth::Formatters::HTML
  include RedCloth::Formatters::Base

  def after_transform(text)
    text.chomp!
    clean_html(text, ALLOWED_TAGS)
  end

  ALLOWED_TAGS = {
    'a' => ['href', 'title'],
    'br' => [],
    'i' => nil
  }
end
于 2011-01-24T16:43:24.327 回答