Only Allow Video Embed Codes (Rails)

2019-04-13 02:53发布

I was wondering if anyone knew of a way to only allow embed codes like ones from youtube, vimeo, blip.tv, etc. into a form field? I have a form on my site that allow users to embed a video but I only want them to add the embed code html and nothing else dangerous like JS or additional html. Is there any tool out there that can do this or can this be done with just a regular expression? Thank you

1条回答
祖国的老花朵
2楼-- · 2019-04-13 03:10

You can possibly try the sanitize helper at http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html with some tweaks.

查看更多
登录 后发表回答