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.
44c645f2c3a008972d9904102bae09df?d=identicon&s=25 matt (Guest)
on 2006-03-03 22: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?
54a6aeb8a51b2522511a6e9566c2c656?d=identicon&s=25 Aurélien DEHAY (Guest)
on 2006-03-04 14: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.
47632046c1a5dbaf00472e2241fbee0d?d=identicon&s=25 David Smalley (Guest)
on 2006-03-04 19: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 Smalley
w: http://davidsmalley.com/blog
This topic is locked and can not be replied to.