[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Plugin Youtube - use http_header_referrer_policy_value for iframe referrerpolicy

"Domeshow Emmanuel \(@Domeshow\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a3aa5d23f432_38ab0cc06002@gitlab-sidekiq-low-urgency-cpu-bound-v2-66fdbcf897-6csw6.mail>

Domeshow Emmanuel pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
adbdf48d by Domeshow Emmanuel at 2026-06-23T18:09:23+03:00
[FIX] Plugin Youtube - use http_header_referrer_policy_value for iframe referrerpolicy
---
* [FIX] Plugin Youtube - align test expectations with default referrer policy

* [FIX] Plugin Youtube - use http_header_referrer_policy_value for iframe referrerpolicy

See merge request tikiwiki/tiki!10577

- - - - -


3 changed files:

- lib/test/wiki-plugins/YoutubeTest.php
- lib/wiki-plugins/shared/embed_helpers.php
- lib/wiki-plugins/wikiplugin_youtube.php


Changes:

=====================================
lib/test/wiki-plugins/YoutubeTest.php
=====================================
@@ -9,6 +9,13 @@ require_once(__DIR__ . '/../../wiki-plugins/wikiplugin_youtube.php');
 
 class WikiPlugin_YoutubeTest extends PHPUnit\Framework\TestCase
 {
+    protected function setUp(): void
+    {
+        global $prefs;
+
+        $prefs['http_header_referrer_policy_value'] = 'strict-origin-when-cross-origin';
+    }
+
     /**
      * @dataProvider provider
      */
@@ -26,6 +33,7 @@ class WikiPlugin_YoutubeTest extends PHPUnit\Framework\TestCase
             if ($expectedSubstring !== '') {
                 $this->assertStringContainsString($expectedSubstring, $result);
             }
+            $this->assertStringContainsString('referrerpolicy="strict-origin-when-cross-origin"', $result);
         }
     }
 


=====================================
lib/wiki-plugins/shared/embed_helpers.php
=====================================
@@ -87,6 +87,9 @@ function buildEmbedContainerAndIframe($iframeSrc, $params = [], $oEmbedData = []
     $iframe->setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture');
     $iframe->setAttribute('title', tra('Embedded media content'));
     $iframe->setAttribute('style', $iframeStyle);
+    if (! empty($params['referrerPolicy'])) {
+        $iframe->setAttribute('referrerpolicy', $params['referrerPolicy']);
+    }
 
     if (! empty($params['allowFullScreen']) && $params['allowFullScreen'] === 'y') {
         $iframe->setAttribute('allowfullscreen', '');


=====================================
lib/wiki-plugins/wikiplugin_youtube.php
=====================================
@@ -155,7 +155,7 @@ function wikiplugin_youtube($data, $params)
         'quality' => 'high',
     ], $params);
 
-    global $tikilib;
+    global $tikilib, $prefs;
 
     // Extract YouTube ID and type (e.g., shorts, live, etc.)
     $youtubeInfo = getYoutubeId($params['movie']);
@@ -197,6 +197,8 @@ function wikiplugin_youtube($data, $params)
         $src .= '?' . implode('&', $queryParams);
     }
 
+    $params['referrerPolicy'] = $prefs['http_header_referrer_policy_value'] ?? '';
+
     $embedHtml = buildEmbedContainerAndIframe($src, $params, $oEmbedData);
     return '~np~' . $embedHtml . '~/np~';
 }



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/adbdf48d31d80f6c05db338d7c77df0774e33cf6

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/adbdf48d31d80f6c05db338d7c77df0774e33cf6
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.