Commit 91b7ec13 authored by Christopher Tombleson's avatar Christopher Tombleson
Browse files

Fixed Youtube html filter.



The html filter will now parse links with underscores in them.

Bug #884438

Change-Id: I117b3162b44ecb372d42454c0d64224d01f363b7
Signed-off-by: default avatarChristopher Tombleson <christopher@catalyst.net.nz>
parent 9fd47999
......@@ -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]+((&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]+)*)?)';
$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