User Submission Video Embed Parse HTML tags

sikuneh

New Member
Messages
55
Reaction score
0
Points
0
I have a user submission site and I want to allow them to embed videos, currently I just let them paste the embed code but I have no way of getting rid of HTML tags that would mess up the CSS (I.E. adding a div without closing it). Is there a good way to fix this?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Having users enter HTML is unnecessary for you and adds needless complexity for them. The safest approach would be to let users enter only the video URL, height and width. If need be, have different templates for different video hosts.

If you still wish to allow HTML, you could use strip_tags (which might have some problems with long tags), however it doesn't filter out attributes (which you could then do by parsing the string using one of the XML manipulation extensions). For a more complete solution, try HTML Purifier.
 

sikuneh

New Member
Messages
55
Reaction score
0
Points
0
I was also thinking about how forums use brakets to parse html.

E.G. [font color=] = <span style="font-color:">

How does that work? I assume it uses preg_replace() or something? Or would using brackets be too complicated?

My thought was [video url=] = <iframe src=> or <embed>. would that work?
 
Last edited:
Top