Forum: Ruby on Rails strip html

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
matt (Guest)
on 2006-03-03 23:12
(Received via mailing list)
say i wanted to allow only certain html characters from my user
submissions, and strip everything else. does rails have a built-in for
this?
Aurélien DEHAY (Guest)
on 2006-03-04 15:01
(Received via mailing list)
matt a écrit :
> say i wanted to allow only certain html characters from my user
> submissions, and strip everything else. does rails have a built-in for
> this?

No, but you should look at RubySoup.
David S. (Guest)
on 2006-03-04 20:15
(Received via mailing list)
On 3 Mar 2006, at 21:09, matt wrote:

> say i wanted to allow only certain html characters from my user
> submissions, and strip everything else. does rails have a built-in
> for this?

I created a helper for my app that strips all html tags and then re-
links anything that is an http or mailto link using the strip_tags
and auto_link functions

def sanitize_text_but_keep_links (text)
     @sanitized_text = strip_tags(text)
     @sanitized_text = auto_link(@sanitized_text)
     return @sanitized_text
   end

David


------------------------
David S.
w: http://davidsmalley.com/blog
This topic is locked and can not be replied to.