From a8340b6d73a67070217724245e3b07afdf002f37 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 13 Dec 2025 12:09:51 -0800 Subject: [PATCH 1/2] Extract phpbb4 check into a method --- event/main_listener.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/event/main_listener.php b/event/main_listener.php index 07ed675..80ae154 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -104,7 +104,6 @@ public function __construct(auth $auth, config $config, db_text $config_text, la */ public function add_custom_sites($event) { - $is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0-a1', '>='); $phpbb4_builtins = array_flip([ 'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter', ]); @@ -114,7 +113,7 @@ public function add_custom_sites($event) $name = basename($site, ext::YML); // Skip built-in sites when running phpBB 4 - if ($is_phpbb4 && isset($phpbb4_builtins[$name])) + if ($this->is_phpbb4() && isset($phpbb4_builtins[$name])) { continue; } @@ -394,4 +393,12 @@ public function append_agreement() $this->template->append_var('AGREEMENT_TEXT', $this->language->lang('MEDIA_EMBED_PRIVACY_POLICY', $this->config['sitename'])); } + + /** + * @return mixed + */ + private function is_phpbb4() + { + return phpbb_version_compare($this->config['version'], '4.0.0-a1', '>='); + } } From 79ce9b837079bf695b2e3646b989376f339dd910 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 13 Dec 2025 12:10:35 -0800 Subject: [PATCH 2/2] Change youtube referrer policy only for phpbb 3 --- event/main_listener.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/event/main_listener.php b/event/main_listener.php index 80ae154..4e19f2d 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -177,7 +177,11 @@ public function modify_tag_templates($event) { // force YouTube to use the no cookies until the user starts video playback, and fix referrer policy issues $tag = $event['configurator']->tags['YOUTUBE']; - $tag->template = str_replace(['www.youtube.com', ' allowfullscreen'], ['www.youtube-nocookie.com', ' referrerpolicy="origin" allowfullscreen'], $tag->template); + $tag->template = str_replace(['www.youtube.com'], 'www.youtube-nocookie.com', $tag->template); + if (!$this->is_phpbb4()) + { + $tag->template = str_replace([' allowfullscreen'], ' referrerpolicy="origin" allowfullscreen', $tag->template); + } $event['configurator']->finalize(); }