Changeset 22366 for trunk/wp-includes/SimplePie/Locator.php
- Timestamp:
- 11/05/2012 02:25:25 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/SimplePie/Locator.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/SimplePie/Locator.php
r21644 r22366 34 34 * 35 35 * @package SimplePie 36 * @version 1.3 36 * @version 1.3.1 37 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 38 38 * @author Ryan Parman … … 73 73 $this->max_checked_feeds = $max_checked_feeds; 74 74 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 } 80 87 } 81 88 … … 163 170 public function get_base() 164 171 { 172 if ($this->dom === null) 173 { 174 throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); 175 } 165 176 $this->http_base = $this->file->url; 166 177 $this->base = $this->http_base; … … 170 181 if ($element->hasAttribute('href')) 171 182 { 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; 173 189 $this->base_location = method_exists($element, 'getLineNo') ? $element->getLineNo() : 0; 174 190 break; … … 197 213 protected function search_elements_by_tag($name, &$done, $feeds) 198 214 { 215 if ($this->dom === null) 216 { 217 throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); 218 } 219 199 220 $links = $this->dom->getElementsByTagName($name); 200 221 foreach ($links as $link) … … 216 237 { 217 238 $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); 239 } 240 if ($href === false) 241 { 242 continue; 218 243 } 219 244 … … 239 264 public function get_links() 240 265 { 266 if ($this->dom === null) 267 { 268 throw new SimplePie_Exception('DOMDocument not found, unable to use locator'); 269 } 270 241 271 $links = $this->dom->getElementsByTagName('a'); 242 272 foreach ($links as $link) … … 255 285 { 256 286 $href = $this->registry->call('Misc', 'absolutize_url', array(trim($link->getAttribute('href')), $this->http_base)); 287 } 288 if ($href === false) 289 { 290 continue; 257 291 } 258 292
Note: See TracChangeset
for help on using the changeset viewer.