]> git.wh0rd.org Git - tt-rss.git/commitdiff
allow embedding videos from youtube and vimeo natively
authorAndrew Dolgov <noreply@fakecake.org>
Tue, 25 Nov 2014 10:45:02 +0000 (13:45 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Tue, 25 Nov 2014 10:45:02 +0000 (13:45 +0300)
include/functions2.php

index 672373e6dddf4fe2b36701c25638ebf8764d3277..866c92ec90b0a3931d753c33ebbdc7b4a70be86e 100644 (file)
 
        }
 
+       function iframe_whitelisted($entry) {
+               $whitelist = array("youtube.com", "youtu.be", "vimeo.com");
+
+               @$src = parse_url($entry->getAttribute("src"), PHP_URL_HOST);
+
+               if ($src) {
+                       foreach ($whitelist as $w) {
+                               if ($src == $w || $src == "www.$w")
+                                       return true;
+                       }
+               }
+
+               return false;
+       }
+
        function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) {
                if (!$owner) $owner = $_SESSION["uid"];
 
 
                $entries = $xpath->query('//iframe');
                foreach ($entries as $entry) {
-                       $entry->setAttribute('sandbox', 'allow-scripts');
+                       if (!iframe_whitelisted($entry)) {
+                               $entry->setAttribute('sandbox', 'allow-scripts');
+                       }
 
                }