Make WordPress Core


Ignore:
Timestamp:
11/05/2012 02:25:25 PM (14 years ago)
Author:
ryan
Message:

Update SimplePie to 1.3.1. Props rmccue, ocean90. fixes #22321

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/SimplePie/Locator.php

    r21644 r22366  
    3434 *
    3535 * @package SimplePie
    36  * @version 1.3
     36 * @version 1.3.1
    3737 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
    3838 * @author Ryan Parman
     
    7373                $this->max_checked_feeds = $max_checked_feeds;
    7474
    75                 $this->dom = new DOMDocument();
    76 
    77                 set_error_handler(array('SimplePie_Misc', 'silence_errors'));
    78                 $this->dom->loadHTML($this->file->body);
    79                 restore_error_handler();
     75                if (class_exists('DOMDocument'))
     76                {
     77                        $this->dom = new DOMDocument();
     78
     79                        set_error_handler(array('SimplePie_Misc', 'silence_errors'));
     80                        $this->dom->loadHTML($this->file->body);
     81                        restore_error_handler();
     82                }
     83                else
     84                {
     85                        $this->dom = null;
     86                }
    8087        }
    8188
     
    163170        public function get_base()
    164171        {
     172                if ($this->dom === null)
     173                {
     174                        throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
     175                }
    165176                $this->http_base = $this->file->url;
    166177                $this->base = $this->http_base;
     
    170181                        if ($element->hasAttribute('href'))
    171182                        {
    172                                 $this->base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base));
     183                                $base = $this->registry->call('Misc', 'absolutize_url', array(trim($element->getAttribute('href')), $this->http_base));
     184                                if ($base === false)
     185                                {
     186                                        continue;
     187                                }
     188                                $this->base = $base;
    173189                                $this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0;
    174190                                break;
     
    197213        protected function search_elements_by_tag($name, &$done, $feeds)
    198214        {
     215                if ($this->dom === null)
     216                {
     217                        throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
     218                }
     219
    199220                $links = $this->dom->getElementsByTagName($name);
    200221                foreach ($links as $link)
     
    216237                                {
    217238                                        $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base));
     239                                }
     240                                if ($href === false)
     241                                {
     242                                        continue;
    218243                                }
    219244
     
    239264        public function get_links()
    240265        {
     266                if ($this->dom === null)
     267                {
     268                        throw new SimplePie_Exception('DOMDocument not found, unable to use locator');
     269                }
     270
    241271                $links = $this->dom->getElementsByTagName('a');
    242272                foreach ($links as $link)
     
    255285                                        {
    256286                                                $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base));
     287                                        }
     288                                        if ($href === false)
     289                                        {
     290                                                continue;
    257291                                        }
    258292
Note: See TracChangeset for help on using the changeset viewer.