0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 16:31:53 +00:00

Update YouTube embed code to new style, fixes #28

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
This commit is contained in:
Edward Z. Yang 2014-08-31 09:30:16 +01:00
parent bf84df4f7d
commit 4da38aca80
2 changed files with 5 additions and 4 deletions

1
NEWS
View File

@ -14,6 +14,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
proprietary one. proprietary one.
- Don't truncate upon encountering </div> when using DOMLex. Thanks - Don't truncate upon encountering </div> when using DOMLex. Thanks
Myrto Christina for finally convincing me to fix this. Myrto Christina for finally convincing me to fix this.
- Update YouTube filter for new code.
4.6.0, released 2013-11-30 4.6.0, released 2013-11-30
# Secure URI munge hashing algorithm has changed to hash_hmac("sha256", $url, $secret). # Secure URI munge hashing algorithm has changed to hash_hmac("sha256", $url, $secret).

View File

@ -17,7 +17,7 @@ class HTMLPurifier_Filter_YouTube extends HTMLPurifier_Filter
public function preFilter($html, $config, $context) public function preFilter($html, $config, $context)
{ {
$pre_regex = '#<object[^>]+>.+?' . $pre_regex = '#<object[^>]+>.+?' .
'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s'; '(?:http:)?//www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s';
$pre_replace = '<span class="youtube-embed">\1</span>'; $pre_replace = '<span class="youtube-embed">\1</span>';
return preg_replace($pre_regex, $pre_replace, $html); return preg_replace($pre_regex, $pre_replace, $html);
} }
@ -51,10 +51,10 @@ class HTMLPurifier_Filter_YouTube extends HTMLPurifier_Filter
{ {
$url = $this->armorUrl($matches[1]); $url = $this->armorUrl($matches[1]);
return '<object width="425" height="350" type="application/x-shockwave-flash" ' . return '<object width="425" height="350" type="application/x-shockwave-flash" ' .
'data="http://www.youtube.com/' . $url . '">' . 'data="//www.youtube.com/' . $url . '">' .
'<param name="movie" value="http://www.youtube.com/' . $url . '"></param>' . '<param name="movie" value="//www.youtube.com/' . $url . '"></param>' .
'<!--[if IE]>' . '<!--[if IE]>' .
'<embed src="http://www.youtube.com/' . $url . '"' . '<embed src="//www.youtube.com/' . $url . '"' .
'type="application/x-shockwave-flash"' . 'type="application/x-shockwave-flash"' .
'wmode="transparent" width="425" height="350" />' . 'wmode="transparent" width="425" height="350" />' .
'<![endif]-->' . '<![endif]-->' .