aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-01-26 08:59:34 +0100
committerGravatar GitHub <noreply@github.com> 2023-01-26 08:59:34 +0100
commit07efaf71eac19934d858df678576823da131d1bb (patch)
tree38cde28b75769272378b0aa3e41047b30901800e /app
parent2f027545226eca238a6a80021cb3ac0e60b51696 (diff)
Fix error handling when updating URL (#5039)
Fix 3 related error handling when updating the feed URL with an invalid URL. Previously leading to unclear 500 page with additional PHP errors.
Diffstat (limited to 'app')
-rw-r--r--app/Controllers/subscriptionController.php5
-rw-r--r--app/Models/Feed.php7
2 files changed, 8 insertions, 4 deletions
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index 315187aaa..c1acfd958 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -256,7 +256,7 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
$url_redirect = array('c' => 'subscription', 'params' => array('id' => $id));
}
- if ($feedDAO->updateFeed($id, $values) !== false) {
+ if ($values['url'] != '' && $feedDAO->updateFeed($id, $values) !== false) {
$feed->_categoryId($values['category']);
// update url and website values for faviconPrepare
$feed->_url($values['url'], false);
@@ -265,6 +265,9 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController {
Minz_Request::good(_t('feedback.sub.feed.updated'), $url_redirect);
} else {
+ if ($values['url'] == '') {
+ Minz_Log::warning('Invalid feed URL!');
+ }
Minz_Request::bad(_t('feedback.sub.feed.error'), $url_redirect);
}
}
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index a63c2b3ea..09cacbd61 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -259,13 +259,14 @@ class FreshRSS_Feed extends Minz_Model {
}
public function _url(string $value, bool $validate = true) {
$this->hash = '';
+ $url = $value;
if ($validate) {
- $value = checkUrl($value);
+ $url = checkUrl($url);
}
- if ($value == '') {
+ if ($url == '') {
throw new FreshRSS_BadUrl_Exception($value);
}
- $this->url = $value;
+ $this->url = $url;
}
public function _kind(int $value) {
$this->kind = $value;