Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3605004
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:04:11+00:00 2026-05-18T21:04:11+00:00

hopefully this is a simple question. I have a simple custom forum on my

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:04:11+00:00Added an answer on May 18, 2026 at 9:04 pm

    You should allow users to use something like this:

    [youtube]http://www.youtube.com/watch?v=te-TiL9YVaE[/youtube]
    

    And then turn it to embed code using PHP when displaying a message:

    function bb_youtube($post) {
        return preg_replace(
                                "#\[youtube].*?v=([^&]+).*?\[/youtube\]#im",
                                '<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/$1?fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$1?fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>',
                                $post
                               );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is hopefully a simple question: I have an OpenGL texture and would like
hopefully a pretty simple question this time. I have a Select method in a
Hopefully this is a simple question and I have just overlooked something somewhere... I
Hopefully this is a pretty simple question for someone to answer. I have a
Hopefully this question has a simple answer i'm overlooking! I have an IIS webserver
This is hopefully a very simple maths question. If I have two number ranges,
This is a (hopefully) really simple question - I have been told recently that
hopefully a simple question here, i have a barcode scanner using Zxing, this is
Hopefully this is a very simple question. I have a makefile pattern rule that
Hopefully this is a quick question. I'm making a simple rock paper scissors game.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.