简体   繁体   中英

Allowing users to only enter specific tags

I'm making an app where I need users to input description using a wysiwyg editor. I cannot trust user input, so I need to only allow a , em , ul , li tags. How do I strip the others easily?

Rails has some sanitizing methods baked in. http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html

These are view helpers, so if you want to sanitize before saving the user input you'll need to include the helpers somewhere useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM