[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [FIX] Plugin Youtube - use http_header_referrer_policy_value for iframe referrerpolicy
"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a3533c740c7d_38196cfc816ee@gitlab-sidekiq-low-urgency-cpu-bound-v2-798c48c846-zrt5h.mail> |
Victor Emanouilov pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki
Commits:
28192994 by Domeshow Emmanuel at 2026-06-19T12:13:29+00: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!10555
- - - - -
2 changed files:
- lib/test/wiki-plugins/YoutubeTest.php
- lib/wiki-plugins/wikiplugin_youtube.php
Changes:
=====================================
lib/test/wiki-plugins/YoutubeTest.php
=====================================
@@ -8,25 +8,35 @@ require_once(__DIR__ . '/../../wiki-plugins/wikiplugin_youtube.php');
class WikiPlugin_YoutubeTest extends PHPUnit\Framework\TestCase
{
- /**
- * @dataProvider provider
- * @param $data
- * @param $expectedOutput
- * @param array $params
- */
- public function testWikiPluginCode($data, $expectedOutput, $params = []): void
+ protected function setUp(): void
{
- $this->assertEquals($expectedOutput, wikiplugin_youtube($data, $params));
+ global $prefs;
+
+ $prefs['http_header_referrer_policy_value'] = 'strict-origin-when-cross-origin';
}
- public static function provider(): array
+ public function testWikiPluginCodeWithDefaultReferrerPolicy(): void
{
- return [
- ['', '{BOX(class="text-bg-light")}Plugin YouTube error: the movie parameter is empty.{BOX}'],
- ['', '~np~<iframe src="//www.youtube.com/embed/bPHuY7QL568?" frameborder="0" width="425" height="350" allowfullscreen=""></iframe>~/np~', ['movie' => 'http://www.youtube.com/watch?v=bPHuY7QL568']],
- ['', '~np~<iframe src="//www.youtube.com/embed/deby_Yb1-ac?" frameborder="0" width="425" height="350" allowfullscreen=""></iframe>~/np~', ['movie' => 'https://www.youtube.com/watch?v=deby_Yb1-ac']],
- ['', '~np~<iframe src="//www.youtube.com/embed/deby_Yb1-ac?" frameborder="0" width="425" height="350" allowfullscreen=""></iframe>~/np~', ['movie' => 'https://youtu.be/deby_Yb1-ac']],
- ['', '~np~<iframe src="//www.youtube-nocookie.com/embed/deby_Yb1-ac?" frameborder="0" width="425" height="350" allowfullscreen=""></iframe>~/np~', ['movie' => 'https://youtu.be/deby_Yb1-ac', 'privacyEnhanced' => 'y']],
- ];
+ global $prefs;
+
+ $referrerPolicy = $prefs['http_header_referrer_policy_value'];
+
+ $this->assertEquals('{BOX(class="text-bg-light")}Plugin YouTube error: the movie parameter is empty.{BOX}', wikiplugin_youtube('', []));
+ $this->assertEquals(
+ '~np~<iframe src="//www.youtube.com/embed/bPHuY7QL568?" frameborder="0" width="425" height="350" allowfullscreen="" referrerpolicy="' . $referrerPolicy . '"></iframe>~/np~',
+ wikiplugin_youtube('', ['movie' => 'http://www.youtube.com/watch?v=bPHuY7QL568'])
+ );
+ $this->assertEquals(
+ '~np~<iframe src="//www.youtube.com/embed/deby_Yb1-ac?" frameborder="0" width="425" height="350" allowfullscreen="" referrerpolicy="' . $referrerPolicy . '"></iframe>~/np~',
+ wikiplugin_youtube('', ['movie' => 'https://www.youtube.com/watch?v=deby_Yb1-ac'])
+ );
+ $this->assertEquals(
+ '~np~<iframe src="//www.youtube.com/embed/deby_Yb1-ac?" frameborder="0" width="425" height="350" allowfullscreen="" referrerpolicy="' . $referrerPolicy . '"></iframe>~/np~',
+ wikiplugin_youtube('', ['movie' => 'https://youtu.be/deby_Yb1-ac'])
+ );
+ $this->assertEquals(
+ '~np~<iframe src="//www.youtube-nocookie.com/embed/deby_Yb1-ac?" frameborder="0" width="425" height="350" allowfullscreen="" referrerpolicy="' . $referrerPolicy . '"></iframe>~/np~',
+ wikiplugin_youtube('', ['movie' => 'https://youtu.be/deby_Yb1-ac', 'privacyEnhanced' => 'y'])
+ );
}
}
=====================================
lib/wiki-plugins/wikiplugin_youtube.php
=====================================
@@ -130,7 +130,7 @@ function wikiplugin_youtube_info()
function wikiplugin_youtube($data, $params)
{
- global $tikilib;
+ global $tikilib, $prefs;
$plugininfo = wikiplugin_youtube_info();
foreach ($plugininfo['params'] as $key => $param) {
@@ -142,8 +142,6 @@ function wikiplugin_youtube($data, $params)
return '{BOX(class="text-bg-light")}' . tra('Plugin YouTube error: the movie parameter is empty.') . '{BOX}';
}
- $scheme = $tikilib->httpScheme();
-
$sYoutubeId = getYoutubeId($params['movie']);
if (empty($sYoutubeId)) {
Feedback::error(tra('Invalid YouTube URL provided'));
@@ -184,8 +182,10 @@ function wikiplugin_youtube($data, $params)
$params['movie'] .= '&color2=0x' . $params['background'];
}
+ // Keep iframe referrer policy aligned with site preference.
+ $iframeReferrerPolicy = $prefs['http_header_referrer_policy_value'] ?? '';
- $iframe = ('<iframe src="' . $params['movie'] . '" frameborder="0" width="' . $params['width'] . '" height="' . $params['height'] . '" allowfullscreen="' . $params['allowFullScreen'] . '"></iframe>');
+ $iframe = ('<iframe src="' . $params['movie'] . '" frameborder="0" width="' . $params['width'] . '" height="' . $params['height'] . '" allowfullscreen="' . $params['allowFullScreen'] . '" referrerpolicy="' . $iframeReferrerPolicy . '"></iframe>');
return '~np~' . $iframe . '~/np~';
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2819299486a46ff48e4255a41910bb76699e017d
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2819299486a46ff48e4255a41910bb76699e017d
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