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

  • Home
  • SEARCH
  • 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 72489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:03:10+00:00 2026-05-10T20:03:10+00:00

I want to allow users to paste <embed> and <object> HTML fragments (video players)

  • 0

I want to allow users to paste <embed> and <object> HTML fragments (video players) via an HTML form. The server-side code is PHP. How can I protect against malicious pasted code, JavaScript, etc? I could parse the pasted code, but I’m not sure I could account for all variations. Is there a better way?

  • 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. 2026-05-10T20:03:10+00:00Added an answer on May 10, 2026 at 8:03 pm

    I’m not really sure what parameters EMBED and OBJECT take as I’ve never really dealt with putting media on a page (which is actually kind of shocking to think about) but I would take a BB Code approach to it and do something like and then you can parse out the URL and anything else, make sure they are legit and make your own <EMBED> tag.

    edit: Alright, something like this should be fine:

    $youtube = '<object width='425' height='344'><param name='movie' value='http://www.youtube.com/v/Z75QSExE0jU&hl=en&fs=1'></param> </param><embed src='http://www.youtube.com/v/Z75QSExE0jU&hl=en&fs=1' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='344'></embed></object>';  $blip = '<embed src='http://blip.tv/play/AZ_iEoaIfA' type='application/x-shockwave-flash' width='640' height='510' allowscriptaccess='always' allowfullscreen='true'></embed>';  preg_match_all('/([A-Za-z]*)\=\'(.+?)\'/', $youtube, $matches1); preg_match_all('/([A-Za-z]*)\=\'(.+?)\'/', $blip, $matches2); print '<pre>' . print_r($matches1, true). '</pre>'; print '<pre>' . print_r($matches2, true). '</pre>'; 

    This will output:

    Array ( [0] => Array     (         [0] => width='425'         [1] => height='344'         [2] => name='movie'         [3] => value='http://www.youtube.com/v/Z75QSExE0jU&hl=en&fs=1'         [4] => src='http://www.youtube.com/v/Z75QSExE0jU&hl=en&fs=1'         [5] => type='application/x-shockwave-flash'         [6] => allowfullscreen='true'         [7] => width='425'         [8] => height='344'     )  [1] => Array     (         [0] => width         [1] => height         [2] => name         [3] => value         [4] => src         [5] => type         [6] => allowfullscreen         [7] => width         [8] => height     )  [2] => Array     (         [0] => 425         [1] => 344         [2] => movie         [3] => http://www.youtube.com/v/Z75QSExE0jU&hl=en&fs=1         [4] => http://www.youtube.com/v/Z75QSExE0jU&hl=en&fs=1         [5] => application/x-shockwave-flash         [6] => true         [7] => 425         [8] => 344     ) )  Array ( [0] => Array     (         [0] => src='http://blip.tv/play/AZ_iEoaIfA'         [1] => type='application/x-shockwave-flash'         [2] => width='640'         [3] => height='510'         [4] => allowscriptaccess='always'         [5] => allowfullscreen='true'     )  [1] => Array     (         [0] => src         [1] => type         [2] => width         [3] => height         [4] => allowscriptaccess         [5] => allowfullscreen     )  [2] => Array     (         [0] => http://blip.tv/play/AZ_iEoaIfA         [1] => application/x-shockwave-flash         [2] => 640         [3] => 510         [4] => always         [5] => true     ) ) 

    From then on it’s pretty straight forward. For things like width/height you can verify them with is_numeric and with the rest you can run the values through htmlentities and construct your own <embed> tag from the information. I am pretty certain this would be safe. You can even make the full-fledged <object> one like YouTube (which I assume works in more places) with links from blip.tv, since you would have all the required data.

    I am sure you may see some quirks with links from other video-sharing websites but this will hopefully get you started. Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 131k
  • Answers 131k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer See the "People" microformat documentation for Google Rich Snippets. Here's… May 12, 2026 at 6:11 am
  • Editorial Team
    Editorial Team added an answer Try System.DBNull insead of null. The DBNull class represents a… May 12, 2026 at 6:11 am
  • Editorial Team
    Editorial Team added an answer An index is a database structure that can help speed… May 12, 2026 at 6:11 am

Related Questions

Since there is apparently no Flash control that can accept bitmap pastes , I
I am looking to access the content of a web page that is going
I am using the class pasted below to listen for the keypress event ctrl
I run a website (sorta like a social network) that I wrote myself. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.