Validating/Allowing YouTube Embed Code

Posted by mellowsoon on Stack Overflow See other posts from Stack Overflow or by mellowsoon
Published on 2010-12-21T10:46:42Z Indexed on 2010/12/21 10:54 UTC
Read the original article Hit count: 235

Filed under:
|

Hi, hopefully this is a simple question. I have a simple custom forum on my site written in PHP. For security reasons I don't allow any HTML in the forum posts. I only allow certain BBCode tags. I would however like to allow embedded YouTube videos.

So my question is this: What's the best (most secure) way to validate the YouTube embed code? YouTube is currently using iframes to embed videos, but obviously I can't just allow the iframe tag. I also need to ensure the src of the iframe is a YouTube URL, and ensure there's no other malicious bits of code in the iframe code.

© Stack Overflow or respective owner

Related posts about php

Related posts about youtube