From 4da38aca801ebf4c178de09cfc6d3fb910f3373b Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 31 Aug 2014 09:30:16 +0100 Subject: [PATCH] Update YouTube embed code to new style, fixes #28 Signed-off-by: Edward Z. Yang --- NEWS | 1 + library/HTMLPurifier/Filter/YouTube.php | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 952b6e73..9b087022 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier proprietary one. - Don't truncate upon encountering when using DOMLex. Thanks Myrto Christina for finally convincing me to fix this. +- Update YouTube filter for new code. 4.6.0, released 2013-11-30 # Secure URI munge hashing algorithm has changed to hash_hmac("sha256", $url, $secret). diff --git a/library/HTMLPurifier/Filter/YouTube.php b/library/HTMLPurifier/Filter/YouTube.php index 411519ad..276d8362 100644 --- a/library/HTMLPurifier/Filter/YouTube.php +++ b/library/HTMLPurifier/Filter/YouTube.php @@ -17,7 +17,7 @@ class HTMLPurifier_Filter_YouTube extends HTMLPurifier_Filter public function preFilter($html, $config, $context) { $pre_regex = '#]+>.+?' . - 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s'; + '(?:http:)?//www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s'; $pre_replace = '\1'; return preg_replace($pre_regex, $pre_replace, $html); } @@ -51,10 +51,10 @@ class HTMLPurifier_Filter_YouTube extends HTMLPurifier_Filter { $url = $this->armorUrl($matches[1]); return '' . - '' . + 'data="//www.youtube.com/' . $url . '">' . + '' . '' .