diff options
| author | 2013-11-06 23:21:14 +0100 | |
|---|---|---|
| committer | 2013-11-06 23:21:14 +0100 | |
| commit | ec052432c081cd0db4717cd3ee3c3f9f47785acc (patch) | |
| tree | 553061f304dbd006e94aa961559830c6a87985f0 /app/models/Feed.php | |
| parent | fe78c7fff3606cc51baae5262ce782381b422b52 (diff) | |
Contournement bug PHP 5.3.3-
Bug #51192 FILTER_VALIDATE_URL will invalidate a hostname that includes
'-'
https://bugs.php.net/bug.php?id=51192
Corrige https://github.com/marienfressinaud/FreshRSS/issues/221
Au passage, désactive la validation des URLS provenant de la base de
données et qui ont déjà été validées.
Diffstat (limited to 'app/models/Feed.php')
| -rw-r--r-- | app/models/Feed.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/app/models/Feed.php b/app/models/Feed.php index 82ef93621..97fa7aabc 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -17,8 +17,12 @@ class Feed extends Model { private $error = false; private $keep_history = false; - public function __construct ($url) { - $this->_url ($url); + public function __construct ($url, $validate=true) { + if ($validate) { + $this->_url ($url); + } else { + $this->url = $url; + } } public function id () { @@ -110,11 +114,16 @@ class Feed extends Model { $this->id = $value; } public function _url ($value) { - if (!is_null ($value) && !preg_match ('#^https?://#', $value)) { + if (empty ($value)) { + throw new BadUrlException ($value); + } + if (!preg_match ('#^https?://#', $value)) { $value = 'http://' . $value; } - if (!is_null ($value) && filter_var ($value, FILTER_VALIDATE_URL)) { + if (filter_var ($value, FILTER_VALIDATE_URL)) { + $this->url = $value; + } elseif (version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($value, '-') > 0) && ($value === filter_var($value, FILTER_SANITIZE_URL))) { //PHP bug #51192 $this->url = $value; } else { throw new BadUrlException ($value); @@ -527,7 +536,7 @@ class HelperFeed { $key = $dao['id']; } - $list[$key] = new Feed ($dao['url']); + $list[$key] = new Feed ($dao['url'], false); $list[$key]->_category ($dao['category']); $list[$key]->_name ($dao['name']); $list[$key]->_website ($dao['website']); |
