From 986c7297e71d926afa584c6de293794a49f69adf Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 2 Dec 2013 20:57:51 +0100 Subject: OPML import plus tolérant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plus correction bug checkUrl() --- lib/lib_rss.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lib/lib_rss.php') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 22e50a424..ae140827c 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -19,13 +19,13 @@ function checkUrl($url) { if (empty ($url)) { return ''; } - if (!preg_match ('#^https?://#i', $value)) { + if (!preg_match ('#^https?://#i', $url)) { $url = 'http://' . $url; } if (filter_var($url, FILTER_VALIDATE_URL) || - (version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($value, '-') > 0) && //PHP bug #51192 - ($value === filter_var($value, FILTER_SANITIZE_URL)))) { - return url; + (version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($url, '-') > 0) && //PHP bug #51192 + ($url === filter_var($url, FILTER_SANITIZE_URL)))) { + return $url; } else { return false; } @@ -113,7 +113,14 @@ function html_only_entity_decode($text) { function opml_import ($xml) { $xml = html_only_entity_decode($xml); //!\ Assume UTF-8 - $opml = simplexml_load_string ($xml); + + $dom = new DOMDocument(); + $dom->recover = true; + $dom->strictErrorChecking = false; + $dom->loadXML($xml); + $this->encoding = 'UTF-8'; + + $opml = simplexml_import_dom($dom); if (!$opml) { throw new OpmlException (); -- cgit v1.2.3