简体   繁体   English

允许用户只输入特定标签

[英]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. 我无法信任用户输入,所以我只需要允许aemulli标签。 How do I strip the others easily? 如何轻松剥离其他人?

Rails has some sanitizing methods baked in. http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html Rails有一些消毒方法.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. 这些是视图助手,因此如果您想在保存用户输入之前进行清理,则需要在有用的地方包含帮助程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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