A free, self-hostable news aggregator…
Add an option to set a custom user agent to retrieve individual feeds (#3494)
Jules-Bertholet800a42172db1
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex 6c9b16ff4..63abc9f45 100755--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -165,9 +165,25 @@ class FreshRSS_feed_Controller extends Minz_ActionController {$http_auth = $user . ':' . $pass;}+ $useragent = Minz_Request::param('curl_params_useragent', '');+ $proxy_address = Minz_Request::param('curl_params', '');+ $proxy_type = Minz_Request::param('proxy_type', '');+ $opts = [];+ if ($proxy_address !== '' && $proxy_type !== '' && in_array($proxy_type, [0, 2, 4, 5, 6, 7])) {+ $opts[CURLOPT_PROXY] = $proxy_address;+ $opts[CURLOPT_PROXYTYPE] = intval($proxy_type);+ }+ if ($cookie !== '') {+ $opts[CURLOPT_COOKIE] = $cookie;+ }+ if ($useragent !== '') {+ $opts[CURLOPT_USERAGENT] = $useragent;+ }+$attributes = array('ssl_verify' => null,'timeout' => null,+ 'curl_params' => empty($opts) ? null : $opts,);if (FreshRSS_Auth::hasAccess('admin')) {$attributes['ssl_verify'] = Minz_Request::paramTernary('ssl_verify');diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.phpindex 1cff6ff56..879c7f905 100644--- a/app/Controllers/subscriptionController.php+++ b/app/Controllers/subscriptionController.php@@ -96,7 +96,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {$pass = trim(Minz_Request::param('http_pass_feed' . $id, ''));$httpAuth = '';- if ($user != '' && $pass != '') { //TODO: Sanitize+ if ($user !== '' && $pass !== '') { //TODO: Sanitize$httpAuth = $user . ':' . $pass;}@@ -113,16 +113,20 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {$feed->_attributes('clear_cache', Minz_Request::paramTernary('clear_cache'));$cookie = Minz_Request::param('curl_params_cookie', '');+ $useragent = Minz_Request::param('curl_params_useragent', '');$proxy_address = Minz_Request::param('curl_params', '');$proxy_type = Minz_Request::param('proxy_type', '');$opts = [];- if ($proxy_address != '' && $proxy_type != '' && in_array($proxy_type, [0, 2, 4, 5, 6, 7])) {+ if ($proxy_address !== '' && $proxy_type !== '' && in_array($proxy_type, [0, 2, 4, 5, 6, 7])) {$opts[CURLOPT_PROXY] = $proxy_address;$opts[CURLOPT_PROXYTYPE] = intval($proxy_type);}- if ($cookie != '') {+ if ($cookie !== '') {$opts[CURLOPT_COOKIE] = $cookie;}+ if ($useragent !== '') {+ $opts[CURLOPT_USERAGENT] = $useragent;+ }$feed->_attributes('curl_params', empty($opts) ? null : $opts);$feed->_attributes('content_action', Minz_Request::param('content_action', 'replace'));diff --git a/app/i18n/cz/sub.php b/app/i18n/cz/sub.phpindex 9e933f60d..19c0bf2a7 100644--- a/app/i18n/cz/sub.php+++ b/app/i18n/cz/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Přidat RSS kanál','ttl' => 'Neobnovovat častěji než','url' => 'URL kanálu',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Zkontrolovat platnost kanálu','website' => 'URL webové stránky','websub' => 'Okamžité oznámení s WebSub',diff --git a/app/i18n/de/sub.php b/app/i18n/de/sub.phpindex 0b74e29d0..8698268f3 100644--- a/app/i18n/de/sub.php+++ b/app/i18n/de/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Einen RSS-Feed hinzufügen','ttl' => 'Aktualisiere automatisch nicht öfter als','url' => 'Feed-URL',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Überprüfen Sie die Gültigkeit des Feeds','website' => 'Webseiten-URL','websub' => 'Sofortbenachrichtigung mit WebSub',diff --git a/app/i18n/en-us/sub.php b/app/i18n/en-us/sub.phpindex 0aa3f7f4c..ee8ece901 100644--- a/app/i18n/en-us/sub.php+++ b/app/i18n/en-us/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Add an RSS feed','ttl' => 'Do not automatically refresh more often than','url' => 'Feed URL',+ 'useragent' => 'Set the user agent for fetching this feed',+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>','validator' => 'Check the validity of the feed','website' => 'Website URL','websub' => 'Instant notification with WebSub',diff --git a/app/i18n/en/sub.php b/app/i18n/en/sub.phpindex 2335addf6..dd230ba1b 100644--- a/app/i18n/en/sub.php+++ b/app/i18n/en/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Add an RSS feed','ttl' => 'Do not automatically refresh more often than','url' => 'Feed URL',+ 'useragent' => 'Set the user agent for fetching this feed',+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>','validator' => 'Check the validity of the feed','website' => 'Website URL','websub' => 'Instant notification with WebSub',diff --git a/app/i18n/es/sub.php b/app/i18n/es/sub.phpindex 32376be75..856b4556e 100755--- a/app/i18n/es/sub.php+++ b/app/i18n/es/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Añadir fuente RSS','ttl' => 'No actualizar de forma automática con una frecuencia mayor a','url' => 'URL de la fuente',+ 'useragent' => 'Selecciona el agente de usario por recuperar la fuente',+ 'useragent_help' => 'Ejemplo: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>','validator' => 'Verifica la validez de la fuente','website' => 'Web de la URL','websub' => 'Notificación inmedaiata con WebSub',diff --git a/app/i18n/fr/sub.php b/app/i18n/fr/sub.phpindex 495c4c086..a2a3d4bc2 100644--- a/app/i18n/fr/sub.php+++ b/app/i18n/fr/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Ajouter un flux RSS','ttl' => 'Ne pas automatiquement rafraîchir plus souvent que','url' => 'URL du flux',+ 'useragent' => 'Sélectionner l’agent utilisateur pour télécharger ce flux',+ 'useragent_help' => 'Exemple: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>','validator' => 'Vérifier la validité du flux','website' => 'URL du site','websub' => 'Notification instantanée par WebSub',diff --git a/app/i18n/he/sub.php b/app/i18n/he/sub.phpindex 3bb576952..5984d5f6c 100644--- a/app/i18n/he/sub.php+++ b/app/i18n/he/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'הוספת הזנה','ttl' => 'אין לרענן אוטומטית יותר מ','url' => 'הזנה URL',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'בדיקות תקינות ההזנה','website' => 'אתר URL','websub' => 'Instant notification with WebSub', // TODO - Translationdiff --git a/app/i18n/it/sub.php b/app/i18n/it/sub.phpindex 9c2fd1b08..3cb71c485 100644--- a/app/i18n/it/sub.php+++ b/app/i18n/it/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Aggiungi RSS feed','ttl' => 'Non aggiornare automaticamente piu di','url' => 'Feed URL', // TODO - Translation+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Controlla la validita del feed ','website' => 'URL del sito','websub' => 'Notifica istantanea con WebSub',diff --git a/app/i18n/kr/sub.php b/app/i18n/kr/sub.phpindex a953808d7..1c04e9fb9 100644--- a/app/i18n/kr/sub.php+++ b/app/i18n/kr/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'RSS 피드 추가','ttl' => '다음 시간이 지나기 전에 새로고침 금지','url' => '피드 URL',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => '피드 유효성 검사','website' => '웹사이트 URL','websub' => 'WebSub을 사용한 즉시 알림',diff --git a/app/i18n/nl/sub.php b/app/i18n/nl/sub.phpindex e6adcb564..9656529b1 100644--- a/app/i18n/nl/sub.php+++ b/app/i18n/nl/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Voeg een RSS-feed toe','ttl' => 'Vernieuw automatisch niet vaker dan','url' => 'Feed-url',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Controleer de geldigheid van de feed','website' => 'Website-url','websub' => 'Directe notificaties met WebSub',diff --git a/app/i18n/oc/sub.php b/app/i18n/oc/sub.phpindex 9b70bdac2..7461facfc 100644--- a/app/i18n/oc/sub.php+++ b/app/i18n/oc/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Ajustar un flux RSS','ttl' => 'Actualizar pas automaticament mai sovent que','url' => 'Flux URL',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Verificar la validitat del flux','website' => 'URL del site','websub' => 'Notificaciones instantáneas amb WebSub',diff --git a/app/i18n/pl/sub.php b/app/i18n/pl/sub.phpindex b1e93f1e8..bea398af5 100644--- a/app/i18n/pl/sub.php+++ b/app/i18n/pl/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Dodaj kanał','ttl' => 'Nie odświeżaj automatycznie częściej niż','url' => 'Adres kanału',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Sprawdź poprawność kanału','website' => 'Adres strony','websub' => 'Instant notification with WebSub', // TODO - Translationdiff --git a/app/i18n/pt-br/sub.php b/app/i18n/pt-br/sub.phpindex 2fd0138ed..286c1c5bd 100644--- a/app/i18n/pt-br/sub.php+++ b/app/i18n/pt-br/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Adicionar o RSS feed','ttl' => 'Não atualize automaticamente mais que','url' => 'URL do Feed',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Verifique a validade do feed','website' => 'URL do site','websub' => 'Notificação instantânea com WebSub',diff --git a/app/i18n/ru/sub.php b/app/i18n/ru/sub.phpindex cd18f56de..05a8024f5 100644--- a/app/i18n/ru/sub.php+++ b/app/i18n/ru/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Add an RSS feed', // TODO - Translation'ttl' => 'Do not automatically refresh more often than', // TODO - Translation'url' => 'Feed URL', // TODO - Translation+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Check the validity of the feed', // TODO - Translation'website' => 'Website URL', // TODO - Translation'websub' => 'Instant notification with WebSub', // TODO - Translationdiff --git a/app/i18n/sk/sub.php b/app/i18n/sk/sub.phpindex b60d16400..98a436f02 100644--- a/app/i18n/sk/sub.php+++ b/app/i18n/sk/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'Pridať kanál RSS','ttl' => 'Automaticky neaktualizovať častejšie ako','url' => 'Odkaz kanála',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Skontrolovať platnosť kanála','website' => 'Odkaz webovej stránky','websub' => 'Okamžité oznámenia cez WebSub',diff --git a/app/i18n/tr/sub.php b/app/i18n/tr/sub.phpindex 83ea31fb2..e9f895dcf 100644--- a/app/i18n/tr/sub.php+++ b/app/i18n/tr/sub.php@@ -90,6 +90,8 @@ return array('title_add' => 'RSS akışı ekle','ttl' => 'Şu kadar süreden fazla otomatik yenileme yapma','url' => 'Akış URL',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => 'Akış geçerliliğini kontrol edin','website' => 'Site URL','websub' => 'WebSub ile anlık bildirim',diff --git a/app/i18n/zh-cn/sub.php b/app/i18n/zh-cn/sub.phpindex 248b5b188..bb3a05b59 100644--- a/app/i18n/zh-cn/sub.php+++ b/app/i18n/zh-cn/sub.php@@ -90,6 +90,8 @@ return array('title_add' => '添加订阅源','ttl' => '最小自动更新间隔','url' => '源地址',+ 'useragent' => 'Set the user agent for fetching this feed', // TODO - Translation+ 'useragent_help' => 'Example: <kbd>Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0)</kbd>', // TODO - Translation'validator' => '检查订阅源有效性','website' => '网站地址','websub' => 'WebSub 即时通知',diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtmlindex 06dc859e1..beb64e5a1 100644--- a/app/views/helpers/feed/update.phtml+++ b/app/views/helpers/feed/update.phtml@@ -327,29 +327,6 @@</div></div>- <div class="form-group">- <label class="group-name" for="path_entries"><?= _t('sub.feed.proxy') ?></label>- <div class="group-controls">- <select class="number" name="proxy_type" id="proxy_type"><?php- $type = '';- if (is_array($this->feed->attributes('curl_params')) && isset($this->feed->attributes('curl_params')[CURLOPT_PROXYTYPE])) {- $type = $this->feed->attributes('curl_params')[CURLOPT_PROXYTYPE];- }- foreach(['' => '', 3 => 'NONE', 0 => 'HTTP', 2 => 'HTTPS', 4 => 'SOCKS4', 6 => 'SOCKS4A', 5 => 'SOCKS5', 7 => 'SOCKS5H'] as $k => $v) {- echo '<option value="' . $k . ($type === $k ? '" selected="selected' : '' ) . '">' . $v . '</option>';- }- ?>- </select>- <div class="stick">- <input type="text" name="curl_params" id="curl_params" class="extend" value="<?=- is_array($this->feed->attributes('curl_params')) && !empty($this->feed->attributes('curl_params')[CURLOPT_PROXY]) ?- $this->feed->attributes('curl_params')[CURLOPT_PROXY] : ''- ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />- </div>- <p class="help"><?= _i('help') ?> <?= _t('sub.feed.proxy_help') ?></p>- </div>- </div>-<div class="form-group"><label class="group-name" for="mark_updated_article_unread"><?= _t('conf.reading.mark_updated_article_unread') ?></label><div class="group-controls">@@ -386,6 +363,42 @@</div></div>+ <div class="form-group">+ <label class="group-name" for="path_entries"><?= _t('sub.feed.useragent') ?></label>+ <div class="group-controls">+ <div class="stick">+ <input type="text" name="curl_params_useragent" id="curl_params_useragent" class="extend" value="<?=+ is_array($this->feed->attributes('curl_params')) && !empty($this->feed->attributes('curl_params')[CURLOPT_USERAGENT]) ?+ $this->feed->attributes('curl_params')[CURLOPT_USERAGENT] : ''+ ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />+ </div>+ <p class="help"><?= _i('help') ?> <?= _t('sub.feed.useragent_help') ?></p>+ </div>+ </div>++ <div class="form-group">+ <label class="group-name" for="path_entries"><?= _t('sub.feed.proxy') ?></label>+ <div class="group-controls">+ <select class="number" name="proxy_type" id="proxy_type"><?php+ $type = '';+ if (is_array($this->feed->attributes('curl_params')) && isset($this->feed->attributes('curl_params')[CURLOPT_PROXYTYPE])) {+ $type = $this->feed->attributes('curl_params')[CURLOPT_PROXYTYPE];+ }+ foreach(['' => '', 3 => 'NONE', 0 => 'HTTP', 2 => 'HTTPS', 4 => 'SOCKS4', 6 => 'SOCKS4A', 5 => 'SOCKS5', 7 => 'SOCKS5H'] as $k => $v) {+ echo '<option value="' . $k . ($type === $k ? '" selected="selected' : '' ) . '">' . $v . '</option>';+ }+ ?>+ </select>+ <div class="stick">+ <input type="text" name="curl_params" id="curl_params" class="extend" value="<?=+ is_array($this->feed->attributes('curl_params')) && !empty($this->feed->attributes('curl_params')[CURLOPT_PROXY]) ?+ $this->feed->attributes('curl_params')[CURLOPT_PROXY] : ''+ ?>" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />+ </div>+ <p class="help"><?= _i('help') ?> <?= _t('sub.feed.proxy_help') ?></p>+ </div>+ </div>+<?php if (FreshRSS_Auth::hasAccess('admin')) { ?><div class="form-group"><label class="group-name" for="timeout"><?= _t('sub.feed.timeout') ?></label>diff --git a/app/views/subscription/add.phtml b/app/views/subscription/add.phtmlindex 44b3a8528..8d1dc6d2d 100644--- a/app/views/subscription/add.phtml+++ b/app/views/subscription/add.phtml@@ -59,8 +59,34 @@</div></div>- <?php if (FreshRSS_Auth::hasAccess('admin')) { ?><legend><?= _t('sub.feed.advanced') ?></legend>+ <div class="form-group">+ <label class="group-name" for="path_entries"><?= _t('sub.feed.useragent') ?></label>+ <div class="group-controls">+ <div class="stick">+ <input type="text" name="curl_params_useragent" id="curl_params_useragent" class="extend" value="" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />+ </div>+ <p class="help"><?= _i('help') ?> <?= _t('sub.feed.useragent_help') ?></p>+ </div>+ </div>++ <div class="form-group">+ <label class="group-name" for="path_entries"><?= _t('sub.feed.proxy') ?></label>+ <div class="group-controls">+ <select class="number" name="proxy_type" id="proxy_type"><?php+ foreach(['' => '', 3 => 'NONE', 0 => 'HTTP', 2 => 'HTTPS', 4 => 'SOCKS4', 6 => 'SOCKS4A', 5 => 'SOCKS5', 7 => 'SOCKS5H'] as $k => $v) {+ echo '<option value="' . $k . '">' . $v . '</option>';+ }+ ?>+ </select>+ <div class="stick">+ <input type="text" name="curl_params" id="curl_params" class="extend" value="" placeholder="<?= _t('gen.short.blank_to_disable') ?>" />+ </div>+ <p class="help"><?= _i('help') ?> <?= _t('sub.feed.proxy_help') ?></p>+ </div>+ </div>++ <?php if (FreshRSS_Auth::hasAccess('admin')) { ?><div class="form-group"><label class="group-name" for="timeout"><?= _t('sub.feed.timeout') ?></label><div class="group-controls">diff --git a/cli/i18n/ignore/en-us.php b/cli/i18n/ignore/en-us.phpindex e81a79e81..7529d7d2d 100644--- a/cli/i18n/ignore/en-us.php+++ b/cli/i18n/ignore/en-us.php@@ -756,6 +756,8 @@ return array('sub.feed.title_add','sub.feed.ttl','sub.feed.url',+ 'sub.feed.useragent',+ 'sub.feed.useragent_help','sub.feed.validator','sub.feed.website','sub.feed.websub',