Skip to content

A free, self-hostable news aggregator…

Implement setting for iframe referrer allowlist (#8672)

Inverlecc64991c1650
diff --git a/README.fr.md b/README.fr.md
index c2d62a077..0be13f659 100644
--- a/README.fr.md
+++ b/README.fr.md
@@ -235,7 +235,7 @@ Voir le [dépôt dédié à ces extensions](https://github.com/FreshRSS/Extensio
| Español (es) | ■■■■■■■■■・ 99% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) |
| فارسی (fa) | ■■■■■■■■■・ 91% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffa+%2F%28TODO%7CDIRTY%29%24%2F) |
| Suomi (fi) | ■■■■■■■■■・ 93% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffi+%2F%28TODO%7CDIRTY%29%24%2F) |
-| Français (fr) | ■■■■■■■■■■ 100% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffr+%2F%28TODO%7CDIRTY%29%24%2F) |
+| Français (fr) | ■■■■■■■■■・ 99% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffr+%2F%28TODO%7CDIRTY%29%24%2F) |
| עברית (he) | ■■■■・・・・・・ 41% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fhe+%2F%28TODO%7CDIRTY%29%24%2F) |
| Magyar (hu) | ■■■■■■■■■・ 97% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fhu+%2F%28TODO%7CDIRTY%29%24%2F) |
| Bahasa Indonesia (id) | ■■■■■■■■■・ 90% | [contribuer](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fid+%2F%28TODO%7CDIRTY%29%24%2F) |
diff --git a/README.md b/README.md
index 7cffc77ec..68973eebb 100644
--- a/README.md
+++ b/README.md
@@ -131,7 +131,7 @@ See the [repository dedicated to those extensions](https://github.com/FreshRSS/E
| Español (es) | ■■■■■■■■■・ 99% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fes+%2F%28TODO%7CDIRTY%29%24%2F) |
| فارسی (fa) | ■■■■■■■■■・ 91% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffa+%2F%28TODO%7CDIRTY%29%24%2F) |
| Suomi (fi) | ■■■■■■■■■・ 93% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffi+%2F%28TODO%7CDIRTY%29%24%2F) |
-| Français (fr) | ■■■■■■■■■■ 100% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffr+%2F%28TODO%7CDIRTY%29%24%2F) |
+| Français (fr) | ■■■■■■■■■・ 99% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Ffr+%2F%28TODO%7CDIRTY%29%24%2F) |
| עברית (he) | ■■■■・・・・・・ 41% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fhe+%2F%28TODO%7CDIRTY%29%24%2F) |
| Magyar (hu) | ■■■■■■■■■・ 97% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fhu+%2F%28TODO%7CDIRTY%29%24%2F) |
| Bahasa Indonesia (id) | ■■■■■■■■■・ 90% | [contribute](https://github.com/search?q=repo%3AFreshRSS%2FFreshRSS+path%3Aapp%2Fi18n%2Fid+%2F%28TODO%7CDIRTY%29%24%2F) |
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index b72dc5743..b90221ca8 100644
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -682,6 +682,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
public function privacyAction(): void {
if (Minz_Request::isPost()) {
FreshRSS_Context::userConf()->retrieve_extension_list = Minz_Request::paramBoolean('retrieve_extension_list');
+ FreshRSS_Context::userConf()->send_referrer_allowlist = Minz_Request::paramTextToArray('send_referrer_allowlist');
FreshRSS_Context::userConf()->save();
invalidateHttpCache();
diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php
index 0160c1b5a..b1331969d 100644
--- a/app/Models/UserConfiguration.php
+++ b/app/Models/UserConfiguration.php
@@ -83,6 +83,7 @@ declare(strict_types=1);
* @property array<string,bool|int|string> $volatile
* @property array<string,array<string,mixed>> $extensions
* @property bool $retrieve_extension_list
+ * @property array<string> $send_referrer_allowlist
*/
final class FreshRSS_UserConfiguration extends Minz_Configuration {
use FreshRSS_FilterActionsTrait;
diff --git a/app/i18n/cs/conf.php b/app/i18n/cs/conf.php
index dea5e1a1a..dd8b1d879 100644
--- a/app/i18n/cs/conf.php
+++ b/app/i18n/cs/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Správa profilu',
diff --git a/app/i18n/de/conf.php b/app/i18n/de/conf.php
index ad87e9d31..d9e424686 100644
--- a/app/i18n/de/conf.php
+++ b/app/i18n/de/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privatsphäre',
'retrieve_extension_list' => 'Erweiterungsliste abrufen',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Profil-Verwaltung',
diff --git a/app/i18n/el/conf.php b/app/i18n/el/conf.php
index 3d429d971..9869479f3 100644
--- a/app/i18n/el/conf.php
+++ b/app/i18n/el/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Profile management', // TODO
diff --git a/app/i18n/en-US/conf.php b/app/i18n/en-US/conf.php
index ef7c377b4..926035f8f 100644
--- a/app/i18n/en-US/conf.php
+++ b/app/i18n/en-US/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // IGNORE
'retrieve_extension_list' => 'Retrieve extension list', // IGNORE
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // IGNORE
),
'profile' => array(
'_' => 'Profile management', // IGNORE
diff --git a/app/i18n/en/conf.php b/app/i18n/en/conf.php
index 3f5cff47e..c3e408149 100644
--- a/app/i18n/en/conf.php
+++ b/app/i18n/en/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy',
'retrieve_extension_list' => 'Retrieve extension list',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)',
),
'profile' => array(
'_' => 'Profile management',
diff --git a/app/i18n/es/conf.php b/app/i18n/es/conf.php
index cc1af6c3a..d1cf0034f 100644
--- a/app/i18n/es/conf.php
+++ b/app/i18n/es/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacidad',
'retrieve_extension_list' => 'Obtener lista de extensiones',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Administración de perfiles',
diff --git a/app/i18n/fa/conf.php b/app/i18n/fa/conf.php
index 0d66b28b6..d847f0fb9 100644
--- a/app/i18n/fa/conf.php
+++ b/app/i18n/fa/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'حریم خصوصی',
'retrieve_extension_list' => 'بازیابی لیست افزونه‌ها',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => ' مدیریت پروفایل',
diff --git a/app/i18n/fi/conf.php b/app/i18n/fi/conf.php
index f89c7131e..5aafb0954 100644
--- a/app/i18n/fi/conf.php
+++ b/app/i18n/fi/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Tietosuoja',
'retrieve_extension_list' => 'Nouda laajennusluettelo',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Profiilien hallinta',
diff --git a/app/i18n/fr/conf.php b/app/i18n/fr/conf.php
index 4ca2665a3..4218a6c34 100644
--- a/app/i18n/fr/conf.php
+++ b/app/i18n/fr/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Vie privée',
'retrieve_extension_list' => 'Récupération de la liste des extensions',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Gestion du profil',
diff --git a/app/i18n/he/conf.php b/app/i18n/he/conf.php
index 0b8d4a4c5..2a23ab0a6 100644
--- a/app/i18n/he/conf.php
+++ b/app/i18n/he/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Profile management', // TODO
diff --git a/app/i18n/hu/conf.php b/app/i18n/hu/conf.php
index f9368e9a1..51d5d31a5 100644
--- a/app/i18n/hu/conf.php
+++ b/app/i18n/hu/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Adatvédelem',
'retrieve_extension_list' => 'Kiterjesztés lista beszerzése',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Profil kezelés',
diff --git a/app/i18n/id/conf.php b/app/i18n/id/conf.php
index a9c72a89d..5cba9a0ab 100644
--- a/app/i18n/id/conf.php
+++ b/app/i18n/id/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privasi',
'retrieve_extension_list' => 'Ambil daftar ekstensi',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Pengelolaan Profil',
diff --git a/app/i18n/it/conf.php b/app/i18n/it/conf.php
index 3b7eddd57..c2c3d1d3a 100644
--- a/app/i18n/it/conf.php
+++ b/app/i18n/it/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // IGNORE
'retrieve_extension_list' => 'Recupero dell’elenco delle estensioni',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Gestione profili',
diff --git a/app/i18n/ja/conf.php b/app/i18n/ja/conf.php
index 083c695b2..c2eba4f42 100644
--- a/app/i18n/ja/conf.php
+++ b/app/i18n/ja/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'プライバシー',
'retrieve_extension_list' => '拡張機能リストを取得する',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'プロフィール',
diff --git a/app/i18n/ko/conf.php b/app/i18n/ko/conf.php
index 60ebc621a..7c48fc4b0 100644
--- a/app/i18n/ko/conf.php
+++ b/app/i18n/ko/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => '프로필 관리',
diff --git a/app/i18n/lv/conf.php b/app/i18n/lv/conf.php
index 80ca1097d..5bf8b219d 100644
--- a/app/i18n/lv/conf.php
+++ b/app/i18n/lv/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Profila pārvalde',
diff --git a/app/i18n/nl/conf.php b/app/i18n/nl/conf.php
index 88643d115..4d04ee863 100644
--- a/app/i18n/nl/conf.php
+++ b/app/i18n/nl/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // IGNORE
'retrieve_extension_list' => 'Extensielijst ophalen',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Profielbeheer',
diff --git a/app/i18n/oc/conf.php b/app/i18n/oc/conf.php
index f917fa35b..deff10c36 100644
--- a/app/i18n/oc/conf.php
+++ b/app/i18n/oc/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Gestion del perfil',
diff --git a/app/i18n/pl/conf.php b/app/i18n/pl/conf.php
index e40045f3b..dbd94993c 100644
--- a/app/i18n/pl/conf.php
+++ b/app/i18n/pl/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Prywatność',
'retrieve_extension_list' => 'Pobieraj listę rozszerzeń',
+ 'send_referrer_allowlist' => 'Strony, które mogą zobaczyć twój adres serwera (%s)',
),
'profile' => array(
'_' => 'Zarządzanie profilem',
diff --git a/app/i18n/pt-BR/conf.php b/app/i18n/pt-BR/conf.php
index 9a21545fb..b572142da 100644
--- a/app/i18n/pt-BR/conf.php
+++ b/app/i18n/pt-BR/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacidade',
'retrieve_extension_list' => 'Recuperar lista de extensões',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Gerenciamento de perfil',
diff --git a/app/i18n/pt-PT/conf.php b/app/i18n/pt-PT/conf.php
index 4a439e610..00845c68e 100644
--- a/app/i18n/pt-PT/conf.php
+++ b/app/i18n/pt-PT/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Gestão de perfil',
diff --git a/app/i18n/ru/conf.php b/app/i18n/ru/conf.php
index ea3db626b..de144608f 100644
--- a/app/i18n/ru/conf.php
+++ b/app/i18n/ru/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Конфиденциальность',
'retrieve_extension_list' => 'Получить список расширений',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Настройки профиля',
diff --git a/app/i18n/sk/conf.php b/app/i18n/sk/conf.php
index b01aebdf8..31cca9406 100644
--- a/app/i18n/sk/conf.php
+++ b/app/i18n/sk/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Správca profilu',
diff --git a/app/i18n/tr/conf.php b/app/i18n/tr/conf.php
index 9d09d3ea6..8b6d6d546 100644
--- a/app/i18n/tr/conf.php
+++ b/app/i18n/tr/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Gizlilik',
'retrieve_extension_list' => 'Eklenti listesini al',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Profil yönetimi',
diff --git a/app/i18n/uk/conf.php b/app/i18n/uk/conf.php
index d1c2b3c2d..a531c336a 100644
--- a/app/i18n/uk/conf.php
+++ b/app/i18n/uk/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Приватність',
'retrieve_extension_list' => 'Завантажувати список розширень',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => 'Керування профілем',
diff --git a/app/i18n/zh-CN/conf.php b/app/i18n/zh-CN/conf.php
index a2fbf4008..228e63d04 100644
--- a/app/i18n/zh-CN/conf.php
+++ b/app/i18n/zh-CN/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => '隐私',
'retrieve_extension_list' => '获取扩展列表',
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => '账户管理',
diff --git a/app/i18n/zh-TW/conf.php b/app/i18n/zh-TW/conf.php
index a8092f81b..b7fb6730a 100644
--- a/app/i18n/zh-TW/conf.php
+++ b/app/i18n/zh-TW/conf.php
@@ -122,6 +122,7 @@ return array(
'privacy' => array(
'_' => 'Privacy', // TODO
'retrieve_extension_list' => 'Retrieve extension list', // TODO
+ 'send_referrer_allowlist' => 'Sites allowed to see your server address (%s)', // TODO
),
'profile' => array(
'_' => '個人資料管理',
diff --git a/app/views/configure/privacy.phtml b/app/views/configure/privacy.phtml
index b9bae1540..1c03cf162 100644
--- a/app/views/configure/privacy.phtml
+++ b/app/views/configure/privacy.phtml
@@ -1,6 +1,13 @@
<?php
/** @var FreshRSS_View $this */
$this->partial('aside_configure');
+
+ $host = parse_url(FreshRSS_Context::systemConf()->base_url);
+ if ($host !== false) {
+ $host = $host['host'] ?? '';
+ } else {
+ $host = '';
+ }
?>
<main class="post">
@@ -17,6 +24,13 @@
</div>
</div>
+ <div class="form-group">
+ <label class="group-name" for="send_referrer_allowlist"><?= _t('conf.privacy.send_referrer_allowlist', $host) ?></label>
+ <div class="group-controls">
+ <textarea id="send_referrer_allowlist" name="send_referrer_allowlist"><?= implode("\n", FreshRSS_Context::userConf()->send_referrer_allowlist) ?></textarea>
+ </div>
+ </div>
+
<div class="form-group form-actions">
<div class="group-controls">
<button type="submit" class="btn btn-important"><?= _t('gen.action.submit') ?></button>
diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml
index 0a109afd0..01c340c5e 100644
--- a/app/views/helpers/javascript_vars.phtml
+++ b/app/views/helpers/javascript_vars.phtml
@@ -4,6 +4,7 @@ declare(strict_types=1);
$mark = FreshRSS_Context::userConf()->mark_when;
$s = FreshRSS_Context::userConf()->shortcuts;
$extData = Minz_ExtensionManager::callHook(Minz_HookType::JsVars, []);
+$canView = FreshRSS_Auth::hasAccess() || FreshRSS_Context::systemConf()->allow_anonymous;
echo json_encode([
'context' => [
'anonymous' => !FreshRSS_Auth::hasAccess(),
@@ -21,7 +22,7 @@ echo json_encode([
'auto_load_more' => FreshRSS_Context::userConf()->auto_load_more && FreshRSS_Context::$sort !== 'rand',
'auto_actualize_feeds' => Minz_Session::paramBoolean('actualize_feeds'),
'nb_parallel_refresh' => max(1, FreshRSS_Context::systemConf()->nb_parallel_refresh),
- 'does_lazyload' => !!FreshRSS_Context::userConf()->lazyload ,
+ 'does_lazyload' => FreshRSS_Context::userConf()->lazyload && !Minz_Request::is('index', 'reader'), // TODO: currently no lazy-loading is being done in reader view
'sides_close_article' => !!FreshRSS_Context::userConf()->sides_close_article,
'sidebar_hidden_by_default' => !!FreshRSS_Context::userConf()->sidebar_hidden_by_default,
'sticky_post' => !!FreshRSS_Context::isStickyPostEnabled(),
@@ -39,6 +40,7 @@ echo json_encode([
'extra.js' => @filemtime(PUBLIC_PATH . '/scripts/extra.js'),
'feed.js' => @filemtime(PUBLIC_PATH . '/scripts/feed.js'),
],
+ 'send_referrer_allowlist' => $canView ? FreshRSS_Context::userConf()->send_referrer_allowlist : [],
'max_favicon_upload_size' => FreshRSS_Context::systemConf()->limits['max_favicon_upload_size'],
'version' => FRESHRSS_VERSION,
],
diff --git a/config-user.default.php b/config-user.default.php
index 7cb77aec9..13b1dae04 100644
--- a/config-user.default.php
+++ b/config-user.default.php
@@ -138,7 +138,9 @@ return array (
'sidebar_hidden_by_default' => false,
# List of enabled FreshRSS extensions.
'extensions_enabled' => [],
+ # Privacy settings
'retrieve_extension_list' => true,
+ 'send_referrer_allowlist' => [],
# Extensions configurations
'extensions' => [],
);
diff --git a/p/scripts/global_view.js b/p/scripts/global_view.js
index ebd65765c..096068641 100644
--- a/p/scripts/global_view.js
+++ b/p/scripts/global_view.js
@@ -1,6 +1,6 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
'use strict';
-/* globals context, init_load_more, init_posts, init_stream */
+/* globals context, init_load_more, init_posts, init_stream, enforce_referrer_allowlist */
let panel_loading = false;
@@ -28,6 +28,7 @@ function load_panel(link) {
el.remove();
});
+ enforce_referrer_allowlist(panel);
init_load_more(panel);
init_posts();
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 9243f5b73..d0bf4334c 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -2154,6 +2154,7 @@ function load_more_posts() {
let lastTransition = transitions.length > 0 ? transitions[transitions.length - 1] : null;
const streamAdopted = document.adoptNode(html.getElementById('stream'));
+ enforce_referrer_allowlist(streamAdopted);
streamAdopted.querySelectorAll('.flux, .transition').forEach(function (div) {
if (lastTransition !== null && div.classList.contains('transition') && div.textContent === lastTransition.textContent) {
lastTransition = null;
@@ -2295,6 +2296,24 @@ function removeFirstLoadSpinner() {
}
}
+function enforce_referrer_allowlist(stream) {
+ for (const iframe of stream.querySelectorAll('div.content iframe[src], div.content iframe[data-original]')) {
+ let hostname;
+ try {
+ hostname = new URL(context.does_lazyload ? iframe.getAttribute('data-original') : iframe.src).hostname;
+ } catch (_) {
+ continue;
+ }
+ if (context.send_referrer_allowlist.includes(hostname) && !iframe.hasAttribute('referrerpolicy')) {
+ iframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
+ if (!context.does_lazyload) {
+ // iframe must be reloaded to apply the `referrerpolicy` change
+ iframe.src = iframe.src; // eslint-disable-line no-self-assign
+ }
+ }
+ }
+}
+
function init_normal() {
const stream = document.getElementById('stream');
if (!stream) {
@@ -2306,6 +2325,7 @@ function init_normal() {
}
init_column_categories();
init_stream(stream);
+ enforce_referrer_allowlist(stream);
init_actualize();
faviconNbUnread();