Ruby Forum Ruby on Rails > sanitize doesn't remove inner html

Posted by dino d. (Guest)
on 19.08.2008 03:30
(Received via mailing list)
Hi -

If I have a forbidden tag, like <a>:

<a>extra stuff</a>

I'd like the whole thing removed.  Sanitize just removes the <a> and </
a> tags.  Is there any easy way to remove the whole thing with
sanitize?

Thanks,
Dino
Posted by Brandon Keepers (Guest)
on 19.08.2008 15:38
(Received via mailing list)
On Mon, Aug 18, 2008 at 9:29 PM, dino d. <dinodorroco@yahoo.com> wrote:

> sanitize?
>
> Thanks,
> Dino


The sanitizer is only going to remove the content of the tag if it's
considered a "bad" tag (like <script>).  You can add tot he list of bad 
tags
by throwing this at the bottom of environment.rb

Rails::Initializer.run do |config|
  config.action_view.sanitized_bad_tags = %w(a strong table)
end

Brandon

--
--------------------------------------------------------------------------------
Sessions by Collective Idea: Ruby on Rails training in a vacation 
setting
http://sessions.collectiveidea.com