Commit 9a1cb6d2 authored by Hugh Davenport's avatar Hugh Davenport Committed by Gerrit Code Review
Browse files

Merge "Fixed Youtube html filter."

parents 4823e171 91b7ec13
......@@ -6,14 +6,14 @@ class HTMLPurifier_Filter_YouTubeIframe extends HTMLPurifier_Filter
public $name = 'YouTubeIframe';
public function preFilter($html, $config, $context) {
$url_regex = '([A-Za-z0-9\-]+(\?[A-Za-z]+=[A-Za-z0-9]+((&|&)[A-Za-z]+=[A-Za-z0-9]+)*)?)';
$url_regex = '([A-Za-z0-9\-_]+(\?[A-Za-z]+=[A-Za-z0-9]+((&|&)[A-Za-z]+=[A-Za-z0-9]+)*)?)';
$pre_regex = '#<iframe\b[a-zA-Z0-9/"=-\s]+?\bsrc="http://www.youtube.com/embed/' . $url_regex . '"[a-zA-Z0-9/"=-\s]*?></iframe>#';
$pre_replace = '<span class="youtube-iframe">\1</span>';
return preg_replace($pre_regex, $pre_replace, $html);
}
public function postFilter($html, $config, $context) {
$url_regex = '([A-Za-z0-9\-]+(\?[A-Za-z]+=[A-Za-z0-9]+((&amp;|&)[A-Za-z]+=[A-Za-z0-9]+)*)?)';
$url_regex = '([A-Za-z0-9\-_]+(\?[A-Za-z]+=[A-Za-z0-9]+((&amp;|&)[A-Za-z]+=[A-Za-z0-9]+)*)?)';
$post_regex = '#<span class="youtube-iframe">' . $url_regex . '</span>#';
return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $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