Commit a8cdf976 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Remove embed tags in htmlpurifier video filter output

parent 2370875c
......@@ -6,19 +6,24 @@ class HTMLPurifier_Filter_GoogleVideo extends HTMLPurifier_Filter
public $name = 'GoogleVideo';
public function preFilter($html, $config, $context) {
$pre_regex = '#<embed\b[^>]+\bsrc="http://video.google.com/googleplayer.swf\?(doc[iI]d=[0-9\-]+(?:&hl=[a-z][a-z])?)[^>]+>\s*</embed>#s';
$pre_regex = '#<embed\b[^>]+\bsrc="http://video.google.com/googleplayer.swf\?(doc[iI]d=[0-9\-]+(?:&(?:amp;)?hl=[a-z][a-z])?)[^>]+>\s*</embed>#s';
$pre_replace = '<span class="googlevideo-embed">\1</span>';
return preg_replace($pre_regex, $pre_replace, $html);
}
public function postFilter($html, $config, $context) {
$post_regex = '#<span class="googlevideo-embed">(doc[iI]d=[0-9\-]+(?:&(?:amp;)?hl=[a-z][a-z])?)</span>#';
$post_replace = '<embed style="width:400px; height:326px;" '.
$post_replace = '<object width="400" height="326" data="http://video.google.com/googleplayer.swf?\1">'.
'<param name="movie" value="http://video.google.com/googleplayer.swf?\1" />'.
'<!--[if IE]>'.
'<embed style="width:400px; height:326px;" '.
'id="VideoPlayback" '.
'type="application/x-shockwave-flash" '.
'src="http://video.google.com/googleplayer.swf?\1" '.
'flashvars="" '.
'</embed>';
'</embed>'.
'<![endif]-->'.
'</object>';
return preg_replace($post_regex, $post_replace, $html);
}
......
......@@ -13,11 +13,14 @@ class HTMLPurifier_Filter_SciVee extends HTMLPurifier_Filter
public function postFilter($html, $config, $context) {
$post_regex = '#<span class="scivee-embed">(id=\d+&(?:amp;)?type=\d+)</span>#';
$post_replace = '<object width="480" height="400">'.
$post_replace = '<object width="480" height="400" '.
'data="http://www.scivee.tv/flash/embedPlayer.swf">'.
'<param name="movie" value="http://www.scivee.tv/flash/embedPlayer.swf" />'.
'<param name="allowscriptaccess" value="always" />'.
'<param name="flashvars" value="\1" />'.
'<!--[if IE]>'.
'<embed src="http://www.scivee.tv/flash/embedPlayer.swf" width="480" height="400" flashvars="\1"></embed>'.
'<![endif]-->'.
'</object>';
return preg_replace($post_regex, $post_replace, $html);
}
......
......@@ -13,16 +13,32 @@ class HTMLPurifier_Filter_TeacherTube extends HTMLPurifier_Filter
public function postFilter($html, $config, $context) {
$post_regex = '#<span class="teachertube-embed">(\d+)</span>#';
$post_replace = '<embed src="http://www.teachertube.com/skin-p/mediaplayer.swf" '.
$post_replace = '<object width="425" height="350" data="http://www.teachertube.com/skin-p/mediaplayer.swf">'.
'<param name="movie" value="http://www.teachertube.com/skin-p/mediaplayer.swf" />'.
'<param name="flashvars" value="'.
'height=350&width=425'.
'&file=http://www.teachertube.com/flvideo/\1.flv'.
'&image=http://www.teachertube.com/thumb/\1.jpg'.
'&location=http://www.teachertube.com/skin-p/mediaplayer.swf'.
'&logo=http://www.teachertube.com/images/greylogo.swf'.
'&frontcolor=0xffffff&backcolor=0x000000&lightcolor=0xFF0000&screencolor=0xffffff'.
'&autostart=false&volume=80&overstretch=fit'.
'" />'.
'<!--[if IE]>'.
'<embed src="http://www.teachertube.com/skin-p/mediaplayer.swf" '.
'width="425" height="350" type="application/x-shockwave-flash" allowfullscreen="true" '.
'flashvars="height=350&width=425'.
'flashvars="'.
'height=350&width=425'.
'&file=http://www.teachertube.com/flvideo/\1.flv'.
'&image=http://www.teachertube.com/thumb/\1.jpg'.
'&location=http://www.teachertube.com/skin-p/mediaplayer.swf'.
'&logo=http://www.teachertube.com/images/greylogo.swf'.
'&frontcolor=0xffffff&backcolor=0x000000&lightcolor=0xFF0000&screencolor=0xffffff'.
'&autostart=false&volume=80&overstretch=fit">'.
'</embed>';
'&autostart=false&volume=80&overstretch=fit'.
'">'.
'</embed>'.
'<![endif]-->'.
'</object>';
return preg_replace($post_regex, $post_replace, $html);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment