diff options
| author | 2021-08-22 13:33:58 +0200 | |
|---|---|---|
| committer | 2021-08-22 13:33:58 +0200 | |
| commit | ee2d2db7807065587664d75de2c617f06c8ee568 (patch) | |
| tree | 1ea3ca94b0497504a33cb19c7831630d9a238417 | |
| parent | 93f759fd4f88cc624b46700f73fb8839e450f820 (diff) | |
Fallback for feeds with empty title (#3787)
* Fallback for feeds with empty title
Address a part of https://github.com/FreshRSS/FreshRSS/issues/3776 for existing feeds
* Also strip www prefix
* Reuse fallback logic
| -rwxr-xr-x | app/Controllers/feedController.php | 5 | ||||
| -rw-r--r-- | app/Models/Feed.php | 6 | ||||
| -rw-r--r-- | app/views/helpers/feed/update.phtml | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 8ee3d5324..d43f05d4a 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -470,10 +470,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } if ($simplePie != null) { - if (trim($feed->name()) == '') { + if ($feed->name(true) == '') { //HTML to HTML-PRE //ENT_COMPAT except '&' $name = strtr(html_only_entity_decode($simplePie->get_title()), array('<' => '<', '>' => '>', '"' => '"')); - $feedProperties['name'] = $name == '' ? $feed->url() : $name; + $feed->_name($name); + $feedProperties['name'] = $feed->name(false); } if (trim($feed->website()) == '') { $website = html_only_entity_decode($simplePie->get_link()); diff --git a/app/Models/Feed.php b/app/Models/Feed.php index e3d8f253e..012bdced8 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -75,8 +75,8 @@ class FreshRSS_Feed extends Minz_Model { $simplePie = $this->load(false, true); return $simplePie == null ? [] : iterator_to_array($this->loadEntries($simplePie)); } - public function name() { - return $this->name; + public function name($raw = false) { + return $raw || $this->name != '' ? $this->name : preg_replace('%^https?://(www[.])?%i', '', $this->url); } public function website() { return $this->website; @@ -198,7 +198,7 @@ class FreshRSS_Feed extends Minz_Model { $this->category = $value >= 0 ? $value : 0; } public function _name($value) { - $this->name = $value === null ? '' : $value; + $this->name = $value === null ? '' : trim($value); } public function _website($value, $validate = true) { if ($validate) { diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml index 23a0e3ffa..4bc9913c1 100644 --- a/app/views/helpers/feed/update.phtml +++ b/app/views/helpers/feed/update.phtml @@ -23,7 +23,7 @@ <div class="form-group"> <label class="group-name" for="name"><?= _t('sub.feed.title') ?></label> <div class="group-controls"> - <input type="text" name="name" id="name" class="extend" value="<?= $this->feed->name() ?>" /> + <input type="text" name="name" id="name" class="extend" value="<?= $this->feed->name(true) ?>" /> </div> </div> <div class="form-group"> |
