diff options
Diffstat (limited to '3rdparty/SimplePie/library/SimplePie/Locator.php')
-rw-r--r-- | 3rdparty/SimplePie/library/SimplePie/Locator.php | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/3rdparty/SimplePie/library/SimplePie/Locator.php b/3rdparty/SimplePie/library/SimplePie/Locator.php index 07270cd37..57e910c22 100644 --- a/3rdparty/SimplePie/library/SimplePie/Locator.php +++ b/3rdparty/SimplePie/library/SimplePie/Locator.php @@ -33,7 +33,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * @package SimplePie - * @version 1.3 + * @version 1.3.1 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue * @author Ryan Parman * @author Geoffrey Sneddon @@ -72,11 +72,18 @@ class SimplePie_Locator $this->timeout = $timeout; $this->max_checked_feeds = $max_checked_feeds; - $this->dom = new DOMDocument(); + if (class_exists('DOMDocument')) + { + $this->dom = new DOMDocument(); - set_error_handler(array('SimplePie_Misc', 'silence_errors')); - $this->dom->loadHTML($this->file->body); - restore_error_handler(); + set_error_handler(array('SimplePie_Misc', 'silence_errors')); + $this->dom->loadHTML($this->file->body); + restore_error_handler(); + } + else + { + $this->dom = null; + } } public function set_registry(SimplePie_Registry $registry) @@ -162,6 +169,10 @@ class SimplePie_Locator public function get_base() { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } $this->http_base = $this->file->url; $this->base = $this->http_base; $elements = $this->dom->getElementsByTagName('base'); @@ -169,7 +180,12 @@ class SimplePie_Locator { if ($element->hasAttribute('href')) { - $this->base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base)); + $base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base)); + if ($base === false) + { + continue; + } + $this->base = $base; $this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0; break; } @@ -196,6 +212,11 @@ class SimplePie_Locator protected function search_elements_by_tag($name, &$done, $feeds) { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } + $links = $this->dom->getElementsByTagName($name); foreach ($links as $link) { @@ -216,6 +237,10 @@ class SimplePie_Locator { $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); } + if ($href === false) + { + continue; + } if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) { @@ -238,6 +263,11 @@ class SimplePie_Locator public function get_links() { + if ($this->dom === null) + { + throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); + } + $links = $this->dom->getElementsByTagName('a'); foreach ($links as $link) { @@ -255,6 +285,10 @@ class SimplePie_Locator { $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); } + if ($href === false) + { + continue; + } $current = $this->registry->call('Misc', 'parse_url', array($this->file->url)); @@ -335,3 +369,4 @@ class SimplePie_Locator return null; } } + |