From 84515bb42229f93abdf4b0c06ca2936e052a421a Mon Sep 17 00:00:00 2001 From: panakour Date: Sat, 5 Oct 2019 00:12:54 +0300 Subject: [PATCH] let iframe for Facebook video --- src/Clean/HtmlCleaner.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Clean/HtmlCleaner.php b/src/Clean/HtmlCleaner.php index ee5bb80..60b31a5 100644 --- a/src/Clean/HtmlCleaner.php +++ b/src/Clean/HtmlCleaner.php @@ -90,7 +90,7 @@ public function setAllowedElements(array $allowedElements) protected function purify(): void { $purifierConfig = HTMLPurifier_Config::createDefault(); - $this->enableIframeForYoutubeAndVimeo($purifierConfig); + $this->enableIframeForYoutubeVimeoFacebook($purifierConfig); $purifierConfig->set('HTML.AllowedElements', $this->allowedElements); if (in_array('a', $this->allowedElements)) { $this->allowedAttributes = array_merge($this->allowedAttributes, ['a.href', 'a.target', 'a.rel']); @@ -127,13 +127,13 @@ public function cleanRelativeUrls() } } - protected function enableIframeForYoutubeAndVimeo($purifierConfig) + protected function enableIframeForYoutubeVimeoFacebook($purifierConfig) { if ($this->dom->getNodeList('iframe')->length) { array_push($this->allowedElements, 'iframe'); array_push($this->allowedAttributes, 'iframe.src'); $purifierConfig->set('HTML.SafeIframe', true); - $purifierConfig->set('URI.SafeIframeRegexp', '%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%'); + $purifierConfig->set('URI.SafeIframeRegexp', '%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/|www\.facebook\.com/plugins/video.php\?)%'); } }