Changeset 47733
- Timestamp:
- 05/01/2020 02:24:42 PM (4 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/SimplePie/Author.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 115 114 return $this->name; 116 115 } 117 else 118 { 119 return null; 120 } 116 117 return null; 121 118 } 122 119 … … 132 129 return $this->link; 133 130 } 134 else 135 { 136 return null; 137 } 131 132 return null; 138 133 } 139 134 … … 149 144 return $this->email; 150 145 } 151 else 152 { 153 return null; 154 } 146 147 return null; 155 148 } 156 149 } 157 -
trunk/src/wp-includes/SimplePie/Cache.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 63 62 */ 64 63 protected static $handlers = array( 65 'mysql' => 'SimplePie_Cache_MySQL', 66 'memcache' => 'SimplePie_Cache_Memcache', 64 'mysql' => 'SimplePie_Cache_MySQL', 65 'memcache' => 'SimplePie_Cache_Memcache', 66 'memcached' => 'SimplePie_Cache_Memcached', 67 'redis' => 'SimplePie_Cache_Redis' 67 68 ); 68 69 -
trunk/src/wp-includes/SimplePie/Cache/Base.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie -
trunk/src/wp-includes/SimplePie/Cache/DB.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie -
trunk/src/wp-includes/SimplePie/Cache/File.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 103 102 public function save($data) 104 103 { 105 if (file_exists($this->name) && is_writ eable($this->name) || file_exists($this->location) && is_writeable($this->location))104 if (file_exists($this->name) && is_writable($this->name) || file_exists($this->location) && is_writable($this->location)) 106 105 { 107 106 if ($data instanceof SimplePie) … … 137 136 public function mtime() 138 137 { 139 if (file_exists($this->name)) 140 { 141 return filemtime($this->name); 142 } 143 return false; 138 return @filemtime($this->name); 144 139 } 145 140 … … 151 146 public function touch() 152 147 { 153 if (file_exists($this->name)) 154 { 155 return touch($this->name); 156 } 157 return false; 148 return @touch($this->name); 158 149 } 159 150 -
trunk/src/wp-includes/SimplePie/Cache/Memcache.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 96 95 ), 97 96 ); 98 $parsed = SimplePie_Cache::parse_URL($location); 99 $this->options['host'] = empty($parsed['host']) ? $this->options['host'] : $parsed['host']; 100 $this->options['port'] = empty($parsed['port']) ? $this->options['port'] : $parsed['port']; 101 $this->options['extras'] = array_merge($this->options['extras'], $parsed['extras']); 97 $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); 98 102 99 $this->name = $this->options['extras']['prefix'] . md5("$name:$type"); 103 100 … … 148 145 if ($data !== false) 149 146 { 150 // essentially ignore the mtime because Memcache expires on it 's own147 // essentially ignore the mtime because Memcache expires on its own 151 148 return time(); 152 149 } … … 166 163 if ($data !== false) 167 164 { 168 return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this-> duration);165 return $this->cache->set($this->name, $data, MEMCACHE_COMPRESSED, (int) $this->options['extras']['timeout']); 169 166 } 170 167 -
trunk/src/wp-includes/SimplePie/Cache/MySQL.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 95 94 'extras' => array( 96 95 'prefix' => '', 96 'cache_purge_time' => 2592000 97 97 ), 98 98 ); 99 $this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); 99 100 $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location)); 100 101 101 102 // Path is prefixed with a "/" … … 131 132 if ($query === false) 132 133 { 134 trigger_error("Can't create " . $this->options['extras']['prefix'] . "cache_data table, check permissions", E_USER_WARNING); 133 135 $this->mysql = null; 136 return; 134 137 } 135 138 } … … 137 140 if (!in_array($this->options['extras']['prefix'] . 'items', $db)) 138 141 { 139 $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');142 $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` MEDIUMBLOB NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))'); 140 143 if ($query === false) 141 144 { 145 trigger_error("Can't create " . $this->options['extras']['prefix'] . "items table, check permissions", E_USER_WARNING); 142 146 $this->mysql = null; 147 return; 143 148 } 144 149 } … … 154 159 { 155 160 if ($this->mysql === null) 161 { 162 return false; 163 } 164 165 $query = $this->mysql->prepare('DELETE i, cd FROM `' . $this->options['extras']['prefix'] . 'cache_data` cd, ' . 166 '`' . $this->options['extras']['prefix'] . 'items` i ' . 167 'WHERE cd.id = i.feed_id ' . 168 'AND cd.mtime < (unix_timestamp() - :purge_time)'); 169 $query->bindValue(':purge_time', $this->options['extras']['cache_purge_time']); 170 171 if (!$query->execute()) 156 172 { 157 173 return false; … … 380 396 return $time; 381 397 } 382 else 383 { 384 return false; 385 } 398 399 return false; 386 400 } 387 401 … … 401 415 $query->bindValue(':time', time()); 402 416 $query->bindValue(':id', $this->id); 403 if ($query->execute() && $query->rowCount() > 0) 404 { 405 return true; 406 } 407 else 408 { 409 return false; 410 } 417 418 return $query->execute() && $query->rowCount() > 0; 411 419 } 412 420 … … 427 435 $query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id'); 428 436 $query2->bindValue(':id', $this->id); 429 if ($query->execute() && $query2->execute()) 430 { 431 return true; 432 } 433 else 434 { 435 return false; 436 } 437 438 return $query->execute() && $query2->execute(); 437 439 } 438 440 } -
trunk/src/wp-includes/SimplePie/Caption.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 133 132 return $this->endTime; 134 133 } 135 else 136 { 137 return null; 138 } 134 135 return null; 139 136 } 140 137 … … 151 148 return $this->lang; 152 149 } 153 else 154 { 155 return null; 156 } 150 151 return null; 157 152 } 158 153 … … 168 163 return $this->startTime; 169 164 } 170 else 171 { 172 return null; 173 } 165 166 return null; 174 167 } 175 168 … … 185 178 return $this->text; 186 179 } 187 else 188 { 189 return null; 190 } 180 181 return null; 191 182 } 192 183 … … 202 193 return $this->type; 203 194 } 204 else 205 { 206 return null; 207 } 195 196 return null; 208 197 } 209 198 } 210 -
trunk/src/wp-includes/SimplePie/Category.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 58 57 * Category identifier 59 58 * 60 * @var string 59 * @var string|null 61 60 * @see get_term 62 61 */ … … 66 65 * Categorization scheme identifier 67 66 * 68 * @var string 67 * @var string|null 69 68 * @see get_scheme() 70 69 */ … … 74 73 * Human readable label 75 74 * 76 * @var string 75 * @var string|null 77 76 * @see get_label() 78 77 */ … … 80 79 81 80 /** 81 * Category type 82 * 83 * category for <category> 84 * subject for <dc:subject> 85 * 86 * @var string|null 87 * @see get_type() 88 */ 89 var $type; 90 91 /** 82 92 * Constructor, used to input the data 83 93 * 84 * @param string $term 85 * @param string $scheme 86 * @param string $label 94 * @param string|null $term 95 * @param string|null $scheme 96 * @param string|null $label 97 * @param string|null $type 87 98 */ 88 public function __construct($term = null, $scheme = null, $label = null )99 public function __construct($term = null, $scheme = null, $label = null, $type = null) 89 100 { 90 101 $this->term = $term; 91 102 $this->scheme = $scheme; 92 103 $this->label = $label; 104 $this->type = $type; 93 105 } 94 106 … … 111 123 public function get_term() 112 124 { 113 if ($this->term !== null) 114 { 115 return $this->term; 116 } 117 else 118 { 119 return null; 120 } 125 return $this->term; 121 126 } 122 127 … … 128 133 public function get_scheme() 129 134 { 130 if ($this->scheme !== null) 131 { 132 return $this->scheme; 133 } 134 else 135 { 136 return null; 137 } 135 return $this->scheme; 138 136 } 139 137 … … 141 139 * Get the human readable label 142 140 * 141 * @param bool $strict 143 142 * @return string|null 144 143 */ 145 public function get_label( )144 public function get_label($strict = false) 146 145 { 147 if ($this->label !== null) 148 { 149 return $this->label; 150 } 151 else 146 if ($this->label === null && $strict !== true) 152 147 { 153 148 return $this->get_term(); 154 149 } 150 return $this->label; 151 } 152 153 /** 154 * Get the category type 155 * 156 * @return string|null 157 */ 158 public function get_type() 159 { 160 return $this->type; 155 161 } 156 162 } -
trunk/src/wp-includes/SimplePie/Content/Type/Sniffer.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 122 121 return $return; 123 122 } 124 else 125 { 126 return $official; 127 } 123 124 return $official; 128 125 } 129 126 elseif ($official === 'text/html') … … 131 128 return $this->feed_or_html(); 132 129 } 133 else 134 { 135 return $official; 136 } 137 } 138 else 139 { 140 return $this->unknown(); 141 } 130 131 return $official; 132 } 133 134 return $this->unknown(); 142 135 } 143 136 … … 160 153 return 'application/octect-stream'; 161 154 } 162 else 163 { 164 return 'text/plain'; 165 } 155 156 return 'text/plain'; 166 157 } 167 158 … … 209 200 return 'image/vnd.microsoft.icon'; 210 201 } 211 else 212 { 213 return $this->text_or_binary(); 214 } 202 203 return $this->text_or_binary(); 215 204 } 216 205 … … 243 232 return 'image/vnd.microsoft.icon'; 244 233 } 245 else 246 { 247 return false; 248 } 234 235 return false; 249 236 } 250 237 … … 257 244 { 258 245 $len = strlen($this->file->body); 259 $pos = strspn($this->file->body, "\x09\x0A\x0D\x20 ");246 $pos = strspn($this->file->body, "\x09\x0A\x0D\x20\xEF\xBB\xBF"); 260 247 261 248 while ($pos < $len) … … 330 317 } 331 318 } 332 -
trunk/src/wp-includes/SimplePie/Copyright.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 105 104 return $this->url; 106 105 } 107 else 108 { 109 return null; 110 } 106 107 return null; 111 108 } 112 109 … … 122 119 return $this->label; 123 120 } 124 else 125 { 126 return null; 127 } 121 122 return null; 128 123 } 129 124 } 130 -
trunk/src/wp-includes/SimplePie/Core.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-20 09, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie -
trunk/src/wp-includes/SimplePie/Credit.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 114 113 return $this->role; 115 114 } 116 else 117 { 118 return null; 119 } 115 116 return null; 120 117 } 121 118 … … 131 128 return $this->scheme; 132 129 } 133 else 134 { 135 return null; 136 } 130 131 return null; 137 132 } 138 133 … … 148 143 return $this->name; 149 144 } 150 else 151 { 152 return null; 153 } 145 146 return null; 154 147 } 155 148 } 156 -
trunk/src/wp-includes/SimplePie/Decode/HTML/Entities.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 119 118 return $this->data[$this->position++]; 120 119 } 121 else 122 { 123 return false; 124 } 120 121 return false; 125 122 } 126 123 … … 141 138 return $data; 142 139 } 143 else 144 { 145 return false; 146 } 140 141 return false; 147 142 } 148 143 … … 169 164 case "\x09": 170 165 case "\x0A": 171 case "\x0B":172 166 case "\x0B": 173 167 case "\x0C": … … 615 609 } 616 610 } 617 -
trunk/src/wp-includes/SimplePie/Enclosure.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 284 283 return $this->bitrate; 285 284 } 286 else 287 { 288 return null; 289 } 285 286 return null; 290 287 } 291 288 … … 303 300 return $captions[$key]; 304 301 } 305 else 306 { 307 return null; 308 } 302 303 return null; 309 304 } 310 305 … … 320 315 return $this->captions; 321 316 } 322 else 323 { 324 return null; 325 } 317 318 return null; 326 319 } 327 320 … … 339 332 return $categories[$key]; 340 333 } 341 else 342 { 343 return null; 344 } 334 335 return null; 345 336 } 346 337 … … 356 347 return $this->categories; 357 348 } 358 else 359 { 360 return null; 361 } 349 350 return null; 362 351 } 363 352 … … 373 362 return $this->channels; 374 363 } 375 else 376 { 377 return null; 378 } 364 365 return null; 379 366 } 380 367 … … 390 377 return $this->copyright; 391 378 } 392 else 393 { 394 return null; 395 } 379 380 return null; 396 381 } 397 382 … … 409 394 return $credits[$key]; 410 395 } 411 else 412 { 413 return null; 414 } 396 397 return null; 415 398 } 416 399 … … 426 409 return $this->credits; 427 410 } 428 else 429 { 430 return null; 431 } 411 412 return null; 432 413 } 433 414 … … 443 424 return $this->description; 444 425 } 445 else 446 { 447 return null; 448 } 426 427 return null; 449 428 } 450 429 … … 452 431 * Get the duration of the enclosure 453 432 * 454 * @param string$convert Convert seconds into hh:mm:ss433 * @param bool $convert Convert seconds into hh:mm:ss 455 434 * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found) 456 435 */ … … 464 443 return $time; 465 444 } 466 else 467 { 468 return $this->duration; 469 } 470 } 471 else 472 { 473 return null; 474 } 445 446 return $this->duration; 447 } 448 449 return null; 475 450 } 476 451 … … 486 461 return $this->expression; 487 462 } 488 else 489 { 490 return 'full'; 491 } 463 464 return 'full'; 492 465 } 493 466 … … 521 494 return $this->framerate; 522 495 } 523 else 524 { 525 return null; 526 } 496 497 return null; 527 498 } 528 499 … … 551 522 return $hashes[$key]; 552 523 } 553 else 554 { 555 return null; 556 } 524 525 return null; 557 526 } 558 527 … … 568 537 return $this->hashes; 569 538 } 570 else 571 { 572 return null; 573 } 539 540 return null; 574 541 } 575 542 … … 585 552 return $this->height; 586 553 } 587 else 588 { 589 return null; 590 } 554 555 return null; 591 556 } 592 557 … … 603 568 return $this->lang; 604 569 } 605 else 606 { 607 return null; 608 } 570 571 return null; 609 572 } 610 573 … … 622 585 return $keywords[$key]; 623 586 } 624 else 625 { 626 return null; 627 } 587 588 return null; 628 589 } 629 590 … … 639 600 return $this->keywords; 640 601 } 641 else 642 { 643 return null; 644 } 602 603 return null; 645 604 } 646 605 … … 656 615 return $this->length; 657 616 } 658 else 659 { 660 return null; 661 } 617 618 return null; 662 619 } 663 620 … … 673 630 return urldecode($this->link); 674 631 } 675 else 676 { 677 return null; 678 } 632 633 return null; 679 634 } 680 635 … … 691 646 return $this->medium; 692 647 } 693 else 694 { 695 return null; 696 } 648 649 return null; 697 650 } 698 651 … … 709 662 return $this->player; 710 663 } 711 else 712 { 713 return null; 714 } 664 665 return null; 715 666 } 716 667 … … 728 679 return $ratings[$key]; 729 680 } 730 else 731 { 732 return null; 733 } 681 682 return null; 734 683 } 735 684 … … 745 694 return $this->ratings; 746 695 } 747 else 748 { 749 return null; 750 } 696 697 return null; 751 698 } 752 699 … … 764 711 return $restrictions[$key]; 765 712 } 766 else 767 { 768 return null; 769 } 713 714 return null; 770 715 } 771 716 … … 781 726 return $this->restrictions; 782 727 } 783 else 784 { 785 return null; 786 } 728 729 return null; 787 730 } 788 731 … … 798 741 return $this->samplingrate; 799 742 } 800 else 801 { 802 return null; 803 } 743 744 return null; 804 745 } 805 746 … … 816 757 return round($length/1048576, 2); 817 758 } 818 else 819 { 820 return null; 821 } 759 760 return null; 822 761 } 823 762 … … 835 774 return $thumbnails[$key]; 836 775 } 837 else 838 { 839 return null; 840 } 776 777 return null; 841 778 } 842 779 … … 852 789 return $this->thumbnails; 853 790 } 854 else 855 { 856 return null; 857 } 791 792 return null; 858 793 } 859 794 … … 869 804 return $this->title; 870 805 } 871 else 872 { 873 return null; 874 } 806 807 return null; 875 808 } 876 809 … … 887 820 return $this->type; 888 821 } 889 else 890 { 891 return null; 892 } 822 823 return null; 893 824 } 894 825 … … 904 835 return $this->width; 905 836 } 906 else 907 { 908 return null; 909 } 837 838 return null; 910 839 } 911 840 … … 943 872 * numeric pixel value (such as `360`) or `auto`. Defaults to `auto`, 944 873 * and it is recommended that you use this default. 945 * - `loop` (boolean): Do you want the media to loop when it s done?874 * - `loop` (boolean): Do you want the media to loop when it's done? 946 875 * Defaults to `false`. 947 876 * - `mediaplayer` (string): The location of the included … … 1367 1296 return 'mp3'; 1368 1297 } 1369 else 1370 { 1371 return null; 1372 } 1373 } 1374 else 1375 { 1376 return $type; 1377 } 1298 1299 return null; 1300 } 1301 1302 return $type; 1378 1303 } 1379 1304 } 1380 -
trunk/src/wp-includes/SimplePie/Exception.php
r22469 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.4-dev 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie -
trunk/src/wp-includes/SimplePie/File.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 65 64 var $error; 66 65 var $method = SIMPLEPIE_FILE_SOURCE_NONE; 67 68 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) 66 var $permanent_url; 67 68 public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false, $curl_options = array()) 69 69 { 70 70 if (class_exists('idna_convert')) … … 72 72 $idn = new idna_convert(); 73 73 $parsed = SimplePie_Misc::parse_url($url); 74 $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);74 $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], NULL); 75 75 } 76 76 $this->url = $url; 77 $this->permanent_url = $url; 77 78 $this->useragent = $useragent; 78 79 if (preg_match('/^http(s)?:\/\//i', $url)) … … 103 104 curl_setopt($fp, CURLOPT_HEADER, 1); 104 105 curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); 106 curl_setopt($fp, CURLOPT_FAILONERROR, 1); 105 107 curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); 106 108 curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); … … 108 110 curl_setopt($fp, CURLOPT_USERAGENT, $useragent); 109 111 curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); 110 if (!ini_get('open_basedir') && !ini_get('safe_mode') &&version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>='))112 if (!ini_get('open_basedir') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) 111 113 { 112 114 curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); 113 115 curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); 114 116 } 117 foreach ($curl_options as $curl_param => $curl_value) { 118 curl_setopt($fp, $curl_param, $curl_value); 119 } 115 120 116 121 $this->headers = curl_exec($fp); … … 127 132 else 128 133 { 129 $info = curl_getinfo($fp); 134 // Use the updated url provided by curl_getinfo after any redirects. 135 if ($info = curl_getinfo($fp)) { 136 $this->url = $info['url']; 137 } 130 138 curl_close($fp); 131 $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); 132 $this->headers = array_pop($this->headers); 139 $this->headers = SimplePie_HTTP_Parser::prepareHeaders($this->headers, $info['redirect_count'] + 1); 133 140 $parser = new SimplePie_HTTP_Parser($this->headers); 134 141 if ($parser->parse()) 135 142 { 136 143 $this->headers = $parser->headers; 137 $this->body = $parser->body;144 $this->body = trim($parser->body); 138 145 $this->status_code = $parser->status_code; 139 146 if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) … … 141 148 $this->redirects++; 142 149 $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); 143 return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 150 $previousStatusCode = $this->status_code; 151 $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 152 $this->permanent_url = ($previousStatusCode == 301) ? $location : $url; 153 return; 144 154 } 145 155 } … … 223 233 $this->redirects++; 224 234 $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); 225 return $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 235 $previousStatusCode = $this->status_code; 236 $this->__construct($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 237 $this->permanent_url = ($previousStatusCode == 301) ? $location : $url; 238 return; 226 239 } 227 240 if (isset($this->headers['content-encoding'])) … … 240 253 else 241 254 { 242 $this->body = $decoder->data;255 $this->body = trim($decoder->data); 243 256 } 244 257 break; … … 283 296 { 284 297 $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; 285 if ( !$this->body = file_get_contents($url))298 if (empty($url) || !($this->body = trim(file_get_contents($url)))) 286 299 { 287 300 $this->error = 'file_get_contents could not read the file'; -
trunk/src/wp-includes/SimplePie/HTTP/Parser.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 157 156 return true; 158 157 } 159 else 160 { 161 $this->http_version = ''; 162 $this->status_code = ''; 163 $this->reason = ''; 164 $this->headers = array(); 165 $this->body = ''; 166 return false; 167 } 158 159 $this->http_version = ''; 160 $this->status_code = ''; 161 $this->reason = ''; 162 $this->headers = array(); 163 $this->body = ''; 164 return false; 168 165 } 169 166 … … 498 495 } 499 496 } 497 498 /** 499 * Prepare headers (take care of proxies headers) 500 * 501 * @param string $headers Raw headers 502 * @param integer $count Redirection count. Default to 1. 503 * 504 * @return string 505 */ 506 static public function prepareHeaders($headers, $count = 1) 507 { 508 $data = explode("\r\n\r\n", $headers, $count); 509 $data = array_pop($data); 510 if (false !== stripos($data, "HTTP/1.0 200 Connection established\r\n\r\n")) { 511 $data = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $data); 512 } 513 if (false !== stripos($data, "HTTP/1.1 200 Connection established\r\n\r\n")) { 514 $data = str_ireplace("HTTP/1.1 200 Connection established\r\n\r\n", '', $data); 515 } 516 return $data; 517 } 500 518 } -
trunk/src/wp-includes/SimplePie/IRI.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 48 47 * @package SimplePie 49 48 * @subpackage HTTP 50 * @author GeoffreySneddon49 * @author Sam Sneddon 51 50 * @author Steve Minutillo 52 51 * @author Ryan McCue 53 * @copyright 2007-2012 GeoffreySneddon, Steve Minutillo, Ryan McCue52 * @copyright 2007-2012 Sam Sneddon, Steve Minutillo, Ryan McCue 54 53 * @license http://www.opensource.org/licenses/bsd-license.php 55 54 */ … … 213 212 return $this->normalization[$this->scheme][$name]; 214 213 } 215 else 216 { 217 return $return; 218 } 214 215 return $return; 219 216 } 220 217 … … 227 224 public function __isset($name) 228 225 { 229 if (method_exists($this, 'get_' . $name) || isset($this->$name)) 230 { 231 return true; 232 } 233 else 234 { 235 return false; 236 } 226 return method_exists($this, 'get_' . $name) || isset($this->$name); 237 227 } 238 228 … … 258 248 { 259 249 $this->set_iri($iri); 250 } 251 252 /** 253 * Clean up 254 */ 255 public function __destruct() { 256 $this->set_iri(null, true); 257 $this->set_path(null, true); 258 $this->set_authority(null, true); 260 259 } 261 260 … … 349 348 return $target; 350 349 } 351 else 352 { 353 return false; 354 } 350 351 return false; 355 352 } 356 353 } … … 389 386 return $match; 390 387 } 391 else 392 { 393 // This can occur when a paragraph is accidentally parsed as a URI 394 return false; 395 } 388 389 // This can occur when a paragraph is accidentally parsed as a URI 390 return false; 396 391 } 397 392 … … 769 764 public function is_valid() 770 765 { 771 $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null; 772 if ($this->ipath !== '' && 773 ( 774 $isauthority && ( 775 $this->ipath[0] !== '/' || 776 substr($this->ipath, 0, 2) === '//' 777 ) || 778 ( 779 $this->scheme === null && 780 !$isauthority && 781 strpos($this->ipath, ':') !== false && 782 (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/')) 783 ) 784 ) 785 ) 786 { 787 return false; 788 } 766 if ($this->ipath === '') return true; 767 768 $isauthority = $this->iuserinfo !== null || $this->ihost !== null || 769 $this->port !== null; 770 if ($isauthority && $this->ipath[0] === '/') return true; 771 772 if (!$isauthority && (substr($this->ipath, 0, 2) === '//')) return false; 773 774 // Relative urls cannot have a colon in the first path segment (and the 775 // slashes themselves are not included so skip the first character). 776 if (!$this->scheme && !$isauthority && 777 strpos($this->ipath, ':') !== false && 778 strpos($this->ipath, '/', 1) !== false && 779 strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false; 789 780 790 781 return true; … … 798 789 * @return bool 799 790 */ 800 public function set_iri($iri )791 public function set_iri($iri, $clear_cache = false) 801 792 { 802 793 static $cache; 794 if ($clear_cache) 795 { 796 $cache = null; 797 return; 798 } 803 799 if (!$cache) 804 800 { … … 822 818 return $return; 823 819 } 824 else 825 { 826 $parsed = $this->parse_iri((string) $iri); 827 if (!$parsed) 828 { 829 return false; 830 } 831 832 $return = $this->set_scheme($parsed['scheme']) 833 && $this->set_authority($parsed['authority']) 834 && $this->set_path($parsed['path']) 835 && $this->set_query($parsed['query']) 836 && $this->set_fragment($parsed['fragment']); 837 838 $cache[$iri] = array($this->scheme, 839 $this->iuserinfo, 840 $this->ihost, 841 $this->port, 842 $this->ipath, 843 $this->iquery, 844 $this->ifragment, 845 $return); 846 return $return; 847 } 820 821 $parsed = $this->parse_iri((string) $iri); 822 if (!$parsed) 823 { 824 return false; 825 } 826 827 $return = $this->set_scheme($parsed['scheme']) 828 && $this->set_authority($parsed['authority']) 829 && $this->set_path($parsed['path']) 830 && $this->set_query($parsed['query']) 831 && $this->set_fragment($parsed['fragment']); 832 833 $cache[$iri] = array($this->scheme, 834 $this->iuserinfo, 835 $this->ihost, 836 $this->port, 837 $this->ipath, 838 $this->iquery, 839 $this->ifragment, 840 $return); 841 return $return; 848 842 } 849 843 … … 880 874 * @return bool 881 875 */ 882 public function set_authority($authority )876 public function set_authority($authority, $clear_cache = false) 883 877 { 884 878 static $cache; 879 if ($clear_cache) 880 { 881 $cache = null; 882 return; 883 } 885 884 if (!$cache) 886 885 $cache = array(); … … 902 901 return $return; 903 902 } 903 904 $remaining = $authority; 905 if (($iuserinfo_end = strrpos($remaining, '@')) !== false) 906 { 907 $iuserinfo = substr($remaining, 0, $iuserinfo_end); 908 $remaining = substr($remaining, $iuserinfo_end + 1); 909 } 904 910 else 905 911 { 906 $remaining = $authority; 907 if (($iuserinfo_end = strrpos($remaining, '@')) !== false) 908 { 909 $iuserinfo = substr($remaining, 0, $iuserinfo_end); 910 $remaining = substr($remaining, $iuserinfo_end + 1); 911 } 912 else 913 { 914 $iuserinfo = null; 915 } 916 if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) 917 { 918 if (($port = substr($remaining, $port_start + 1)) === false) 919 { 920 $port = null; 921 } 922 $remaining = substr($remaining, 0, $port_start); 923 } 924 else 912 $iuserinfo = null; 913 } 914 if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false) 915 { 916 if (($port = substr($remaining, $port_start + 1)) === false) 925 917 { 926 918 $port = null; 927 919 } 928 929 $return = $this->set_userinfo($iuserinfo) && 930 $this->set_host($remaining) && 931 $this->set_port($port); 932 933 $cache[$authority] = array($this->iuserinfo, 934 $this->ihost, 935 $this->port, 936 $return); 937 938 return $return; 939 } 920 $remaining = substr($remaining, 0, $port_start); 921 } 922 else 923 { 924 $port = null; 925 } 926 927 $return = $this->set_userinfo($iuserinfo) && 928 $this->set_host($remaining) && 929 $this->set_port($port); 930 931 $cache[$authority] = array($this->iuserinfo, 932 $this->ihost, 933 $this->port, 934 $return); 935 936 return $return; 940 937 } 941 938 … … 1037 1034 return true; 1038 1035 } 1039 else 1040 { 1041 $this->port = null; 1042 return false; 1043 } 1036 1037 $this->port = null; 1038 return false; 1044 1039 } 1045 1040 … … 1050 1045 * @return bool 1051 1046 */ 1052 public function set_path($ipath )1047 public function set_path($ipath, $clear_cache = false) 1053 1048 { 1054 1049 static $cache; 1050 if ($clear_cache) 1051 { 1052 $cache = null; 1053 return; 1054 } 1055 1055 if (!$cache) 1056 1056 { … … 1167 1167 $iri .= $this->ipath; 1168 1168 } 1169 1169 elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '') 1170 1170 { 1171 1171 $iri .= $this->normalization[$this->scheme]['ipath']; … … 1211 1211 $iauthority .= $this->ihost; 1212 1212 } 1213 if ($this->port !== null)1213 if ($this->port !== null && $this->port !== 0) 1214 1214 { 1215 1215 $iauthority .= ':' . $this->port; … … 1217 1217 return $iauthority; 1218 1218 } 1219 else 1220 { 1221 return null; 1222 } 1219 1220 return null; 1223 1221 } 1224 1222 … … 1233 1231 if (is_string($iauthority)) 1234 1232 return $this->to_uri($iauthority); 1235 else 1236 1233 1234 return $iauthority; 1237 1235 } 1238 1236 } -
trunk/src/wp-includes/SimplePie/Item.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 123 122 public function __destruct() 124 123 { 125 if ( (version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))124 if (!gc_enabled()) 126 125 { 127 126 unset($this->feed); … … 149 148 return $this->data['child'][$namespace][$tag]; 150 149 } 151 else 152 { 153 return null; 154 } 150 151 return null; 155 152 } 156 153 … … 204 201 * Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute 205 202 * for RDF. If none of these are supplied (or `$hash` is true), creates an 206 * MD5 hash based on the permalink and title. If either of those are not 207 * supplied, creates a hash based on the full feed data. 203 * MD5 hash based on the permalink, title and content. 208 204 * 209 205 * @since Beta 2 210 206 * @param boolean $hash Should we force using a hash instead of the supplied ID? 211 * @return string 212 */ 213 public function get_id($hash = false) 207 * @param string|false $fn User-supplied function to generate an hash 208 * @return string|null 209 */ 210 public function get_id($hash = false, $fn = 'md5') 214 211 { 215 212 if (!$hash) … … 239 236 return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT); 240 237 } 241 elseif (($return = $this->get_permalink()) !== null) 242 { 243 return $return; 244 } 245 elseif (($return = $this->get_title()) !== null) 246 { 247 return $return; 248 } 249 } 250 if ($this->get_permalink() !== null || $this->get_title() !== null) 251 { 252 return md5($this->get_permalink() . $this->get_title()); 253 } 254 else 255 { 256 return md5(serialize($this->data)); 257 } 238 } 239 if ($fn === false) 240 { 241 return null; 242 } 243 elseif (!is_callable($fn)) 244 { 245 trigger_error('User-supplied function $fn must be callable', E_USER_WARNING); 246 $fn = 'md5'; 247 } 248 return call_user_func($fn, 249 $this->get_permalink().$this->get_title().$this->get_content()); 258 250 } 259 251 … … 323 315 public function get_description($description_only = false) 324 316 { 325 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) 326 { 327 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 328 } 329 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) 330 { 331 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 332 } 333 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) 334 { 335 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 336 } 337 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) 338 { 339 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 340 } 341 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) 342 { 343 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 344 } 345 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) 346 { 347 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 348 } 349 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) 350 { 351 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 352 } 353 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) 354 { 355 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 356 } 357 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) 358 { 359 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML); 317 if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) && 318 ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) 319 { 320 return $return; 321 } 322 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) && 323 ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) 324 { 325 return $return; 326 } 327 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) && 328 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0])))) 329 { 330 return $return; 331 } 332 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) && 333 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) 334 { 335 return $return; 336 } 337 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) && 338 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) 339 { 340 return $return; 341 } 342 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) && 343 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) 344 { 345 return $return; 346 } 347 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) && 348 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) 349 { 350 return $return; 351 } 352 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) && 353 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))) 354 { 355 return $return; 356 } 357 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) && 358 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML))) 359 { 360 return $return; 360 361 } 361 362 … … 364 365 return $this->get_content(true); 365 366 } 366 else 367 { 368 return null; 369 } 367 368 return null; 370 369 } 371 370 … … 386 385 public function get_content($content_only = false) 387 386 { 388 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) 389 { 390 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 391 } 392 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) 393 { 394 return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 395 } 396 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) 397 { 398 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 387 if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) && 388 ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) 389 { 390 return $return; 391 } 392 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) && 393 ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0])))) 394 { 395 return $return; 396 } 397 elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) && 398 ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0])))) 399 { 400 return $return; 399 401 } 400 402 elseif (!$content_only) … … 402 404 return $this->get_description(true); 403 405 } 404 else 405 { 406 return null; 407 } 406 407 return null; 408 } 409 410 /** 411 * Get the media:thumbnail of the item 412 * 413 * Uses `<media:thumbnail>` 414 * 415 * 416 * @return array|null 417 */ 418 public function get_thumbnail() 419 { 420 if (!isset($this->data['thumbnail'])) 421 { 422 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) 423 { 424 $this->data['thumbnail'] = $return[0]['attribs']['']; 425 } 426 else 427 { 428 $this->data['thumbnail'] = null; 429 } 430 } 431 return $this->data['thumbnail']; 408 432 } 409 433 … … 422 446 return $categories[$key]; 423 447 } 424 else 425 { 426 return null; 427 } 448 449 return null; 428 450 } 429 451 … … 434 456 * 435 457 * @since Beta 3 436 * @return array|null List of {@see SimplePie_Category} objects458 * @return SimplePie_Category[]|null List of {@see SimplePie_Category} objects 437 459 */ 438 460 public function get_categories() … … 440 462 $categories = array(); 441 463 442 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) 464 $type = 'category'; 465 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, $type) as $category) 443 466 { 444 467 $term = null; … … 457 480 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 458 481 } 459 $categories[] = $this->registry->create('Category', array($term, $scheme, $label ));460 } 461 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category)482 $categories[] = $this->registry->create('Category', array($term, $scheme, $label, $type)); 483 } 484 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, $type) as $category) 462 485 { 463 486 // This is really the label, but keep this as the term also for BC. … … 472 495 $scheme = null; 473 496 } 474 $categories[] = $this->registry->create('Category', array($term, $scheme, null)); 475 } 476 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) 477 { 478 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); 479 } 480 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) 481 { 482 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); 497 $categories[] = $this->registry->create('Category', array($term, $scheme, null, $type)); 498 } 499 500 $type = 'subject'; 501 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, $type) as $category) 502 { 503 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null, $type)); 504 } 505 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, $type) as $category) 506 { 507 $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null, $type)); 483 508 } 484 509 … … 487 512 return array_unique($categories); 488 513 } 489 else 490 { 491 return null; 492 } 514 515 return null; 493 516 } 494 517 … … 507 530 return $authors[$key]; 508 531 } 509 else 510 { 511 return null; 512 } 532 533 return null; 513 534 } 514 535 … … 527 548 return $contributors[$key]; 528 549 } 529 else 530 { 531 return null; 532 } 550 551 return null; 533 552 } 534 553 … … 539 558 * 540 559 * @since 1.1 541 * @return array|null List of {@see SimplePie_Author} objects560 * @return SimplePie_Author[]|null List of {@see SimplePie_Author} objects 542 561 */ 543 562 public function get_contributors() … … 593 612 return array_unique($contributors); 594 613 } 595 else 596 { 597 return null; 598 } 614 615 return null; 599 616 } 600 617 … … 605 622 * 606 623 * @since Beta 2 607 * @return array|null List of {@see SimplePie_Author} objects624 * @return SimplePie_Author[]|null List of {@see SimplePie_Author} objects 608 625 */ 609 626 public function get_authors() … … 683 700 return $authors; 684 701 } 685 else 686 { 687 return null; 688 } 702 703 return null; 689 704 } 690 705 … … 711 726 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 712 727 } 713 else 714 { 715 return null; 716 } 728 729 return null; 717 730 } 718 731 … … 739 752 $this->data['date']['raw'] = $return[0]['data']; 740 753 } 754 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) 755 { 756 $this->data['date']['raw'] = $return[0]['data']; 757 } 758 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) 759 { 760 $this->data['date']['raw'] = $return[0]['data']; 761 } 762 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) 763 { 764 $this->data['date']['raw'] = $return[0]['data']; 765 } 741 766 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) 742 767 { … … 752 777 } 753 778 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) 754 {755 $this->data['date']['raw'] = $return[0]['data'];756 }757 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate'))758 {759 $this->data['date']['raw'] = $return[0]['data'];760 }761 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date'))762 {763 $this->data['date']['raw'] = $return[0]['data'];764 }765 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date'))766 779 { 767 780 $this->data['date']['raw'] = $return[0]['data']; … … 793 806 } 794 807 } 795 else 796 { 797 return null; 798 } 808 809 return null; 799 810 } 800 811 … … 822 833 { 823 834 $parser = $this->registry->call('Parse_Date', 'get'); 824 $this->data['updated']['parsed'] = $parser->parse($this->data[' date']['raw']);835 $this->data['updated']['parsed'] = $parser->parse($this->data['updated']['raw']); 825 836 } 826 837 else … … 844 855 } 845 856 } 846 else 847 { 848 return null; 849 } 857 858 return null; 850 859 } 851 860 … … 873 882 return strftime($date_format, $date); 874 883 } 875 else 876 { 877 return null; 878 } 884 885 return null; 879 886 } 880 887 … … 937 944 return $enclosure->get_link(); 938 945 } 939 else 940 { 941 return null; 942 } 946 947 return null; 943 948 } 944 949 … … 954 959 { 955 960 $links = $this->get_links($rel); 956 if ($links [$key] !== null)961 if ($links && $links[$key] !== null) 957 962 { 958 963 return $links[$key]; 959 964 } 960 else 961 { 962 return null; 963 } 965 966 return null; 964 967 } 965 968 … … 1041 1044 return $this->data['links'][$rel]; 1042 1045 } 1043 else 1044 { 1045 return null; 1046 } 1046 1047 return null; 1047 1048 } 1048 1049 … … 1064 1065 return $enclosures[$key]; 1065 1066 } 1066 else 1067 { 1068 return null; 1069 } 1067 1068 return null; 1070 1069 } 1071 1070 … … 1081 1080 * @since Beta 2 1082 1081 * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4). 1083 * @todo If an element exists at a level, but it 's value is empty, we should fall back to the value from the parent (if it exists).1084 * @return array|null List of SimplePie_Enclosure items1082 * @todo If an element exists at a level, but its value is empty, we should fall back to the value from the parent (if it exists). 1083 * @return SimplePie_Enclosure[]|null List of SimplePie_Enclosure items 1085 1084 */ 1086 1085 public function get_enclosures() … … 2659 2658 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 2660 2659 { 2661 $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 2660 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'])) { 2661 $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 2662 } 2662 2663 } 2663 2664 else … … 2734 2735 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) 2735 2736 { 2736 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 2737 if (isset($thumbnail['attribs']['']['url'])) { 2738 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 2739 } 2737 2740 } 2738 2741 if (is_array($thumbnails)) … … 2790 2793 $length = ceil($link['attribs']['']['length']); 2791 2794 } 2795 if (isset($link['attribs']['']['title'])) 2796 { 2797 $title = $this->sanitize($link['attribs']['']['title'], SIMPLEPIE_CONSTRUCT_TEXT); 2798 } 2799 else 2800 { 2801 $title = $title_parent; 2802 } 2792 2803 2793 2804 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor 2794 $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title _parent, $width));2805 $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title, $width)); 2795 2806 } 2796 2807 } … … 2878 2889 return $this->data['enclosures']; 2879 2890 } 2880 else 2881 { 2882 return null; 2883 } 2891 2892 return null; 2884 2893 } 2885 2894 … … 2906 2915 return (float) $match[1]; 2907 2916 } 2908 else 2909 { 2910 return null; 2911 } 2917 2918 return null; 2912 2919 } 2913 2920 … … 2938 2945 return (float) $match[2]; 2939 2946 } 2940 else 2941 { 2942 return null; 2943 } 2947 2948 return null; 2944 2949 } 2945 2950 … … 2956 2961 return $this->registry->create('Source', array($this, $return[0])); 2957 2962 } 2958 else 2959 { 2960 return null; 2961 } 2963 2964 return null; 2962 2965 } 2963 2966 } 2964 -
trunk/src/wp-includes/SimplePie/Locator.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 64 63 var $checked_feeds = 0; 65 64 var $max_checked_feeds = 10; 65 var $force_fsockopen = false; 66 var $curl_options = array(); 66 67 protected $registry; 67 68 68 public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10 )69 public function __construct(SimplePie_File $file, $timeout = 10, $useragent = null, $max_checked_feeds = 10, $force_fsockopen = false, $curl_options = array()) 69 70 { 70 71 $this->file = $file; … … 72 73 $this->timeout = $timeout; 73 74 $this->max_checked_feeds = $max_checked_feeds; 75 $this->force_fsockopen = $force_fsockopen; 76 $this->curl_options = $curl_options; 74 77 75 78 if (class_exists('DOMDocument')) … … 122 125 if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) 123 126 { 124 return $working ;127 return $working[0]; 125 128 } 126 129 127 130 if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) 128 131 { 129 return $working ;132 return $working[0]; 130 133 } 131 134 132 135 if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) 133 136 { 134 return $working ;137 return $working[0]; 135 138 } 136 139 137 140 if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) 138 141 { 139 return $working ;140 } 141 } 142 return null; 143 } 144 145 public function is_feed($file )142 return $working[0]; 143 } 144 } 145 return null; 146 } 147 148 public function is_feed($file, $check_html = false) 146 149 { 147 150 if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) … … 149 152 $sniffer = $this->registry->create('Content_Type_Sniffer', array($file)); 150 153 $sniffed = $sniffer->get_type(); 151 if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) 152 { 153 return true; 154 } 155 else 156 { 157 return false; 158 } 154 $mime_types = array('application/rss+xml', 'application/rdf+xml', 155 'text/rdf', 'application/atom+xml', 'text/xml', 156 'application/xml', 'application/x-rss+xml'); 157 if ($check_html) 158 { 159 $mime_types[] = 'text/html'; 160 } 161 162 return in_array($sniffed, $mime_types); 159 163 } 160 164 elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) … … 205 209 return array_values($feeds); 206 210 } 207 else 208 { 209 return null; 210 } 211 212 return null; 211 213 } 212 214 … … 227 229 if ($link->hasAttribute('href') && $link->hasAttribute('rel')) 228 230 { 229 $rel = array_unique($this->registry->call('Misc', 'space_sep erated_tokens', array(strtolower($link->getAttribute('rel')))));231 $rel = array_unique($this->registry->call('Misc', 'space_separated_tokens', array(strtolower($link->getAttribute('rel'))))); 230 232 $line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1; 231 233 … … 243 245 } 244 246 245 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]))247 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('text/html', 'application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) 246 248 { 247 249 $this->checked_feeds++; … … 249 251 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', 250 252 ); 251 $feed = $this->registry->create('File', array($href, $this->timeout, 5, $headers, $this->useragent ));252 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed ))253 $feed = $this->registry->create('File', array($href, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options)); 254 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed, true)) 253 255 { 254 256 $feeds[$href] = $feed; … … 276 278 $href = trim($link->getAttribute('href')); 277 279 $parsed = $this->registry->call('Misc', 'parse_url', array($href)); 278 if ($parsed['scheme'] === '' || preg_match('/^(http (s)|feed)?$/i', $parsed['scheme']))280 if ($parsed['scheme'] === '' || preg_match('/^(https?|feed)?$/i', $parsed['scheme'])) 279 281 { 280 282 if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo()) … … 313 315 } 314 316 317 public function get_rel_link($rel) 318 { 319 if ($this->dom === null) 320 { 321 throw new SimplePie_Exception('DOMDocument not found, unable to use '. 322 'locator'); 323 } 324 if (!class_exists('DOMXpath')) 325 { 326 throw new SimplePie_Exception('DOMXpath not found, unable to use '. 327 'get_rel_link'); 328 } 329 330 $xpath = new DOMXpath($this->dom); 331 $query = '//a[@rel and @href] | //link[@rel and @href]'; 332 foreach ($xpath->query($query) as $link) 333 { 334 $href = trim($link->getAttribute('href')); 335 $parsed = $this->registry->call('Misc', 'parse_url', array($href)); 336 if ($parsed['scheme'] === '' || 337 preg_match('/^https?$/i', $parsed['scheme'])) 338 { 339 if (method_exists($link, 'getLineNo') && 340 $this->base_location < $link->getLineNo()) 341 { 342 $href = 343 $this->registry->call('Misc', 'absolutize_url', 344 array(trim($link->getAttribute('href')), 345 $this->base)); 346 } 347 else 348 { 349 $href = 350 $this->registry->call('Misc', 'absolutize_url', 351 array(trim($link->getAttribute('href')), 352 $this->http_base)); 353 } 354 if ($href === false) 355 { 356 return null; 357 } 358 $rel_values = explode(' ', strtolower($link->getAttribute('rel'))); 359 if (in_array($rel, $rel_values)) 360 { 361 return $href; 362 } 363 } 364 } 365 return null; 366 } 367 315 368 public function extension(&$array) 316 369 { … … 328 381 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', 329 382 ); 330 $feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent ));383 $feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options)); 331 384 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) 332 385 { 333 return $feed;386 return array($feed); 334 387 } 335 388 else … … 350 403 break; 351 404 } 352 if (preg_match('/( rss|rdf|atom|xml)/i', $value))405 if (preg_match('/(feed|rss|rdf|atom|xml)/i', $value)) 353 406 { 354 407 $this->checked_feeds++; … … 356 409 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', 357 410 ); 358 $feed = $this->registry->create('File', array($value, $this->timeout, 5, null, $this->useragent ));411 $feed = $this->registry->create('File', array($value, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->curl_options)); 359 412 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) 360 413 { 361 return $feed;414 return array($feed); 362 415 } 363 416 else … … 370 423 } 371 424 } 372 -
trunk/src/wp-includes/SimplePie/Misc.php
r24589 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 139 138 { 140 139 $key = strtolower($key); 141 $full .= " $key=\"" . htmlspecialchars($value['data'] ) . '"';140 $full .= " $key=\"" . htmlspecialchars($value['data'], ENT_COMPAT, 'UTF-8') . '"'; 142 141 } 143 142 if ($element['self_closing']) … … 219 218 return substr_replace($url, 'itpc', 0, 4); 220 219 } 221 else 222 { 223 return $url; 224 } 220 221 return $url; 222 } 223 224 public static function array_merge_recursive($array1, $array2) 225 { 226 foreach ($array2 as $key => $value) 227 { 228 if (is_array($value)) 229 { 230 $array1[$key] = SimplePie_Misc::array_merge_recursive($array1[$key], $value); 231 } 232 else 233 { 234 $array1[$key] = $value; 235 } 236 } 237 238 return $array1; 225 239 } 226 240 … … 261 275 return chr($integer); 262 276 } 263 else 264 { 265 return strtoupper($match[0]); 266 } 277 278 return strtoupper($match[0]); 267 279 } 268 280 … … 318 330 return $return; 319 331 } 332 // This is third, as behaviour of this varies with OS userland and PHP version 333 elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output))) 334 { 335 return $return; 336 } 320 337 // This is last, as behaviour of this varies with OS userland and PHP version 321 elseif ( function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output)))338 elseif (class_exists('\UConverter') && ($return = SimplePie_Misc::change_encoding_uconverter($data, $input, $output))) 322 339 { 323 340 return $return; 324 341 } 342 325 343 // If we can't do anything, just fail 326 else 327 { 328 return false; 329 } 344 return false; 330 345 } 331 346 … … 371 386 { 372 387 return @iconv($input, $output, $data); 388 } 389 390 /** 391 * @param string $data 392 * @param string $input 393 * @param string $output 394 * @return string|false 395 */ 396 protected static function change_encoding_uconverter($data, $input, $output) 397 { 398 return @\UConverter::transcode($data, $output, $input); 373 399 } 374 400 … … 1827 1853 return trim($mime); 1828 1854 } 1829 else 1830 { 1831 return trim(substr($mime, 0, $pos)); 1832 } 1855 1856 return trim(substr($mime, 0, $pos)); 1833 1857 } 1834 1858 … … 1863 1887 } 1864 1888 } 1865 else 1866 { 1867 return SIMPLEPIE_CONSTRUCT_TEXT | $mode; 1868 } 1889 1890 return SIMPLEPIE_CONSTRUCT_TEXT | $mode; 1869 1891 } 1870 1892 … … 1916 1938 } 1917 1939 } 1918 else 1919 { 1920 return SIMPLEPIE_CONSTRUCT_TEXT; 1921 } 1940 1941 return SIMPLEPIE_CONSTRUCT_TEXT; 1922 1942 } 1923 1943 … … 1927 1947 } 1928 1948 1929 public static function space_sep erated_tokens($string)1949 public static function space_separated_tokens($string) 1930 1950 { 1931 1951 $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; … … 1976 1996 return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); 1977 1997 } 1978 else 1979 { 1980 // U+FFFD REPLACEMENT CHARACTER 1981 return "\xEF\xBF\xBD"; 1982 } 1998 1999 // U+FFFD REPLACEMENT CHARACTER 2000 return "\xEF\xBF\xBD"; 1983 2001 } 1984 2002 … … 2184 2202 return filemtime(dirname(__FILE__) . '/Core.php'); 2185 2203 } 2186 else 2187 { 2188 return filemtime(__FILE__); 2189 } 2204 2205 return filemtime(__FILE__); 2190 2206 } 2191 2207 … … 2245 2261 } 2246 2262 } 2247 -
trunk/src/wp-includes/SimplePie/Net/IPv6.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 55 54 * @author elfrink at introweb dot nl 56 55 * @author Josh Peck <jmp at joshpeck dot org> 57 * @author GeoffreySneddon <geoffers@gmail.com>56 * @author Sam Sneddon <geoffers@gmail.com> 58 57 */ 59 58 class SimplePie_Net_IPv6 … … 175 174 return implode(':', $ip_parts); 176 175 } 177 else 178 { 179 return $ip_parts[0]; 180 } 176 177 return $ip_parts[0]; 181 178 } 182 179 … … 202 199 return array($ipv6_part, $ipv4_part); 203 200 } 204 else 205 { 206 return array($ip, ''); 207 } 201 202 return array($ip, ''); 208 203 } 209 204 … … 255 250 return true; 256 251 } 257 else 258 { 259 return false; 260 } 252 253 return false; 261 254 } 262 255 -
trunk/src/wp-includes/SimplePie/Parse/Date.php
r46260 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 100 99 // German 101 100 'montag' => 1, 101 'mo' => 1, 102 102 'dienstag' => 2, 103 'di' => 2, 103 104 'mittwoch' => 3, 105 'mi' => 3, 104 106 'donnerstag' => 4, 107 'do' => 4, 105 108 'freitag' => 5, 109 'fr' => 5, 106 110 'samstag' => 6, 111 'sa' => 6, 107 112 'sonnabend' => 6, 113 // AFAIK no short form for sonnabend 114 'so' => 7, 108 115 'sonntag' => 7, 109 116 // Italian … … 147 154 'Σαβ' => 6, 148 155 'Κυρ' => 7, 156 // Russian 157 'Пн.' => 1, 158 'Вт.' => 2, 159 'Ср.' => 3, 160 'Чт.' => 4, 161 'Пт.' => 5, 162 'Сб.' => 6, 163 'Вс.' => 7, 149 164 ); 150 165 … … 174 189 'august' => 8, 175 190 'sep' => 9, 176 'september' => 8,191 'september' => 9, 177 192 'oct' => 10, 178 193 'october' => 10, … … 209 224 // German 210 225 'januar' => 1, 226 'jan' => 1, 211 227 'februar' => 2, 228 'feb' => 2, 212 229 'märz' => 3, 230 'mär' => 3, 213 231 'april' => 4, 214 'mai' => 5, 232 'apr' => 4, 233 'mai' => 5, // no short form for may 215 234 'juni' => 6, 235 'jun' => 6, 216 236 'juli' => 7, 237 'jul' => 7, 217 238 'august' => 8, 239 'aug' => 8, 218 240 'september' => 9, 241 'sep' => 9, 219 242 'oktober' => 10, 243 'okt' => 10, 220 244 'november' => 11, 245 'nov' => 11, 221 246 'dezember' => 12, 247 'dez' => 12, 222 248 // Italian 223 249 'gennaio' => 1, … … 291 317 'Οκτ' => 10, 292 318 'Νοέ' => 11, 293 'Δεκ' => 12, 319 'Δεκ' => 12, 320 // Russian 321 'Янв' => 1, 322 'января' => 1, 323 'Фев' => 2, 324 'февраля' => 2, 325 'Мар' => 3, 326 'марта' => 3, 327 'Апр' => 4, 328 'апреля' => 4, 329 'Май' => 5, 330 'мая' => 5, 331 'Июн' => 6, 332 'июня' => 6, 333 'Июл' => 7, 334 'июля' => 7, 335 'Авг' => 8, 336 'августа' => 8, 337 'Сен' => 9, 338 'сентября' => 9, 339 'Окт' => 10, 340 'октября' => 10, 341 'Ноя' => 11, 342 'ноября' => 11, 343 'Дек' => 12, 344 'декабря' => 12, 345 294 346 ); 295 347 … … 615 667 * @final 616 668 * @access public 617 * @param call able$callback669 * @param callback $callback 618 670 */ 619 671 public function add_callback($callback) … … 632 684 * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as 633 685 * well as allowing any of upper or lower case "T", horizontal tabs, or 634 * spaces to be used as the time sep erator (including more than one))686 * spaces to be used as the time separator (including more than one)) 635 687 * 636 688 * @access protected … … 692 744 693 745 // Convert the number of seconds to an integer, taking decimals into account 694 $second = round( $match[6] + $match[7] / pow(10,strlen($match[7])));746 $second = round((int)$match[6] + (int)$match[7] / (10 ** strlen($match[7]))); 695 747 696 748 return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; 697 749 } 698 else 699 { 700 return false; 701 } 750 751 return false; 702 752 } 703 753 … … 722 772 $output .= substr($string, $position, $pos - $position); 723 773 $position = $pos + 1; 724 if ($ string[$pos - 1] !== '\\')774 if ($pos === 0 || $string[$pos - 1] !== '\\') 725 775 { 726 776 $depth++; … … 850 900 return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; 851 901 } 852 else 853 { 854 return false; 855 } 902 903 return false; 856 904 } 857 905 … … 915 963 return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; 916 964 } 917 else 918 { 919 return false; 920 } 965 966 return false; 921 967 } 922 968 … … 957 1003 return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); 958 1004 } 959 else 960 { 961 return false; 962 } 1005 1006 return false; 963 1007 } 964 1008 … … 976 1020 return false; 977 1021 } 978 else 979 { 980 return $strtotime; 981 } 1022 1023 return $strtotime; 982 1024 } 983 1025 } 984 -
trunk/src/wp-includes/SimplePie/Parser.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 76 75 } 77 76 78 public function parse(&$data, $encoding) 79 { 77 public function parse(&$data, $encoding, $url = '') 78 { 79 if (class_exists('DOMXpath') && function_exists('Mf2\parse')) { 80 $doc = new DOMDocument(); 81 @$doc->loadHTML($data); 82 $xpath = new DOMXpath($doc); 83 // Check for both h-feed and h-entry, as both a feed with no entries 84 // and a list of entries without an h-feed wrapper are both valid. 85 $query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '. 86 'contains(concat(" ", @class, " "), " h-entry ")]'; 87 $result = $xpath->query($query); 88 if ($result->length !== 0) { 89 return $this->parse_microformats($data, $url); 90 } 91 } 92 80 93 // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character 81 94 if (strtoupper($encoding) === 'US-ASCII') … … 121 134 { 122 135 $data = substr($data, $pos + 2); 123 $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data;136 $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' ."\n". $this->declare_html_entities() . $data; 124 137 } 125 138 else … … 164 177 return $return; 165 178 } 166 else 167 { 168 libxml_clear_errors(); 169 $xml = new XMLReader(); 170 $xml->xml($data); 171 while (@$xml->read()) 172 { 173 switch ($xml->nodeType) 174 { 175 176 case constant('XMLReader::END_ELEMENT'): 179 180 libxml_clear_errors(); 181 $xml = new XMLReader(); 182 $xml->xml($data); 183 while (@$xml->read()) 184 { 185 switch ($xml->nodeType) 186 { 187 188 case constant('XMLReader::END_ELEMENT'): 189 if ($xml->namespaceURI !== '') 190 { 191 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; 192 } 193 else 194 { 195 $tagName = $xml->localName; 196 } 197 $this->tag_close(null, $tagName); 198 break; 199 case constant('XMLReader::ELEMENT'): 200 $empty = $xml->isEmptyElement; 201 if ($xml->namespaceURI !== '') 202 { 203 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; 204 } 205 else 206 { 207 $tagName = $xml->localName; 208 } 209 $attributes = array(); 210 while ($xml->moveToNextAttribute()) 211 { 177 212 if ($xml->namespaceURI !== '') 178 213 { 179 $ tagName = $xml->namespaceURI . $this->separator . $xml->localName;214 $attrName = $xml->namespaceURI . $this->separator . $xml->localName; 180 215 } 181 216 else 182 217 { 183 $tagName = $xml->localName; 184 } 218 $attrName = $xml->localName; 219 } 220 $attributes[$attrName] = $xml->value; 221 } 222 $this->tag_open(null, $tagName, $attributes); 223 if ($empty) 224 { 185 225 $this->tag_close(null, $tagName); 186 break; 187 case constant('XMLReader::ELEMENT'): 188 $empty = $xml->isEmptyElement; 189 if ($xml->namespaceURI !== '') 190 { 191 $tagName = $xml->namespaceURI . $this->separator . $xml->localName; 192 } 193 else 194 { 195 $tagName = $xml->localName; 196 } 197 $attributes = array(); 198 while ($xml->moveToNextAttribute()) 199 { 200 if ($xml->namespaceURI !== '') 201 { 202 $attrName = $xml->namespaceURI . $this->separator . $xml->localName; 203 } 204 else 205 { 206 $attrName = $xml->localName; 207 } 208 $attributes[$attrName] = $xml->value; 209 } 210 $this->tag_open(null, $tagName, $attributes); 211 if ($empty) 212 { 213 $this->tag_close(null, $tagName); 214 } 215 break; 216 case constant('XMLReader::TEXT'): 217 218 case constant('XMLReader::CDATA'): 219 $this->cdata(null, $xml->value); 220 break; 221 } 222 } 223 if ($error = libxml_get_last_error()) 224 { 225 $this->error_code = $error->code; 226 $this->error_string = $error->message; 227 $this->current_line = $error->line; 228 $this->current_column = $error->column; 229 return false; 230 } 231 else 232 { 233 return true; 234 } 235 } 226 } 227 break; 228 case constant('XMLReader::TEXT'): 229 230 case constant('XMLReader::CDATA'): 231 $this->cdata(null, $xml->value); 232 break; 233 } 234 } 235 if ($error = libxml_get_last_error()) 236 { 237 $this->error_code = $error->code; 238 $this->error_string = $error->message; 239 $this->current_line = $error->line; 240 $this->current_column = $error->column; 241 return false; 242 } 243 244 return true; 236 245 } 237 246 … … 405 414 return $cache[$string]; 406 415 } 416 417 private function parse_hcard($data, $category = false) { 418 $name = ''; 419 $link = ''; 420 // Check if h-card is set and pass that information on in the link. 421 if (isset($data['type']) && in_array('h-card', $data['type'])) { 422 if (isset($data['properties']['name'][0])) { 423 $name = $data['properties']['name'][0]; 424 } 425 if (isset($data['properties']['url'][0])) { 426 $link = $data['properties']['url'][0]; 427 if ($name === '') { 428 $name = $link; 429 } 430 else { 431 // can't have commas in categories. 432 $name = str_replace(',', '', $name); 433 } 434 $person_tag = $category ? '<span class="person-tag"></span>' : ''; 435 return '<a class="h-card" href="'.$link.'">'.$person_tag.$name.'</a>'; 436 } 437 } 438 return isset($data['value']) ? $data['value'] : ''; 439 } 440 441 private function parse_microformats(&$data, $url) { 442 $feed_title = ''; 443 $feed_author = NULL; 444 $author_cache = array(); 445 $items = array(); 446 $entries = array(); 447 $mf = Mf2\parse($data, $url); 448 // First look for an h-feed. 449 $h_feed = array(); 450 foreach ($mf['items'] as $mf_item) { 451 if (in_array('h-feed', $mf_item['type'])) { 452 $h_feed = $mf_item; 453 break; 454 } 455 // Also look for h-feed or h-entry in the children of each top level item. 456 if (!isset($mf_item['children'][0]['type'])) continue; 457 if (in_array('h-feed', $mf_item['children'][0]['type'])) { 458 $h_feed = $mf_item['children'][0]; 459 // In this case the parent of the h-feed may be an h-card, so use it as 460 // the feed_author. 461 if (in_array('h-card', $mf_item['type'])) $feed_author = $mf_item; 462 break; 463 } 464 else if (in_array('h-entry', $mf_item['children'][0]['type'])) { 465 $entries = $mf_item['children']; 466 // In this case the parent of the h-entry list may be an h-card, so use 467 // it as the feed_author. 468 if (in_array('h-card', $mf_item['type'])) $feed_author = $mf_item; 469 break; 470 } 471 } 472 if (isset($h_feed['children'])) { 473 $entries = $h_feed['children']; 474 // Also set the feed title and store author from the h-feed if available. 475 if (isset($mf['items'][0]['properties']['name'][0])) { 476 $feed_title = $mf['items'][0]['properties']['name'][0]; 477 } 478 if (isset($mf['items'][0]['properties']['author'][0])) { 479 $feed_author = $mf['items'][0]['properties']['author'][0]; 480 } 481 } 482 else if (count($entries) === 0) { 483 $entries = $mf['items']; 484 } 485 for ($i = 0; $i < count($entries); $i++) { 486 $entry = $entries[$i]; 487 if (in_array('h-entry', $entry['type'])) { 488 $item = array(); 489 $title = ''; 490 $description = ''; 491 if (isset($entry['properties']['url'][0])) { 492 $link = $entry['properties']['url'][0]; 493 if (isset($link['value'])) $link = $link['value']; 494 $item['link'] = array(array('data' => $link)); 495 } 496 if (isset($entry['properties']['uid'][0])) { 497 $guid = $entry['properties']['uid'][0]; 498 if (isset($guid['value'])) $guid = $guid['value']; 499 $item['guid'] = array(array('data' => $guid)); 500 } 501 if (isset($entry['properties']['name'][0])) { 502 $title = $entry['properties']['name'][0]; 503 if (isset($title['value'])) $title = $title['value']; 504 $item['title'] = array(array('data' => $title)); 505 } 506 if (isset($entry['properties']['author'][0]) || isset($feed_author)) { 507 // author is a special case, it can be plain text or an h-card array. 508 // If it's plain text it can also be a url that should be followed to 509 // get the actual h-card. 510 $author = isset($entry['properties']['author'][0]) ? 511 $entry['properties']['author'][0] : $feed_author; 512 if (!is_string($author)) { 513 $author = $this->parse_hcard($author); 514 } 515 else if (strpos($author, 'http') === 0) { 516 if (isset($author_cache[$author])) { 517 $author = $author_cache[$author]; 518 } 519 else { 520 $mf = Mf2\fetch($author); 521 foreach ($mf['items'] as $hcard) { 522 // Only interested in an h-card by itself in this case. 523 if (!in_array('h-card', $hcard['type'])) { 524 continue; 525 } 526 // It must have a url property matching what we fetched. 527 if (!isset($hcard['properties']['url']) || 528 !(in_array($author, $hcard['properties']['url']))) { 529 continue; 530 } 531 // Save parse_hcard the trouble of finding the correct url. 532 $hcard['properties']['url'][0] = $author; 533 // Cache this h-card for the next h-entry to check. 534 $author_cache[$author] = $this->parse_hcard($hcard); 535 $author = $author_cache[$author]; 536 break; 537 } 538 } 539 } 540 $item['author'] = array(array('data' => $author)); 541 } 542 if (isset($entry['properties']['photo'][0])) { 543 // If a photo is also in content, don't need to add it again here. 544 $content = ''; 545 if (isset($entry['properties']['content'][0]['html'])) { 546 $content = $entry['properties']['content'][0]['html']; 547 } 548 $photo_list = array(); 549 for ($j = 0; $j < count($entry['properties']['photo']); $j++) { 550 $photo = $entry['properties']['photo'][$j]; 551 if (!empty($photo) && strpos($content, $photo) === false) { 552 $photo_list[] = $photo; 553 } 554 } 555 // When there's more than one photo show the first and use a lightbox. 556 // Need a permanent, unique name for the image set, but don't have 557 // anything unique except for the content itself, so use that. 558 $count = count($photo_list); 559 if ($count > 1) { 560 $image_set_id = preg_replace('/[[:^alnum:]]/', '', $photo_list[0]); 561 $description = '<p>'; 562 for ($j = 0; $j < $count; $j++) { 563 $hidden = $j === 0 ? '' : 'class="hidden" '; 564 $description .= '<a href="'.$photo_list[$j].'" '.$hidden. 565 'data-lightbox="image-set-'.$image_set_id.'">'. 566 '<img src="'.$photo_list[$j].'"></a>'; 567 } 568 $description .= '<br><b>'.$count.' photos</b></p>'; 569 } 570 else if ($count == 1) { 571 $description = '<p><img src="'.$photo_list[0].'"></p>'; 572 } 573 } 574 if (isset($entry['properties']['content'][0]['html'])) { 575 // e-content['value'] is the same as p-name when they are on the same 576 // element. Use this to replace title with a strip_tags version so 577 // that alt text from images is not included in the title. 578 if ($entry['properties']['content'][0]['value'] === $title) { 579 $title = strip_tags($entry['properties']['content'][0]['html']); 580 $item['title'] = array(array('data' => $title)); 581 } 582 $description .= $entry['properties']['content'][0]['html']; 583 if (isset($entry['properties']['in-reply-to'][0])) { 584 $in_reply_to = ''; 585 if (is_string($entry['properties']['in-reply-to'][0])) { 586 $in_reply_to = $entry['properties']['in-reply-to'][0]; 587 } 588 else if (isset($entry['properties']['in-reply-to'][0]['value'])) { 589 $in_reply_to = $entry['properties']['in-reply-to'][0]['value']; 590 } 591 if ($in_reply_to !== '') { 592 $description .= '<p><span class="in-reply-to"></span> '. 593 '<a href="'.$in_reply_to.'">'.$in_reply_to.'</a><p>'; 594 } 595 } 596 $item['description'] = array(array('data' => $description)); 597 } 598 if (isset($entry['properties']['category'])) { 599 $category_csv = ''; 600 // Categories can also contain h-cards. 601 foreach ($entry['properties']['category'] as $category) { 602 if ($category_csv !== '') $category_csv .= ', '; 603 if (is_string($category)) { 604 // Can't have commas in categories. 605 $category_csv .= str_replace(',', '', $category); 606 } 607 else { 608 $category_csv .= $this->parse_hcard($category, true); 609 } 610 } 611 $item['category'] = array(array('data' => $category_csv)); 612 } 613 if (isset($entry['properties']['published'][0])) { 614 $timestamp = strtotime($entry['properties']['published'][0]); 615 $pub_date = date('F j Y g:ia', $timestamp).' GMT'; 616 $item['pubDate'] = array(array('data' => $pub_date)); 617 } 618 // The title and description are set to the empty string to represent 619 // a deleted item (which also makes it an invalid rss item). 620 if (isset($entry['properties']['deleted'][0])) { 621 $item['title'] = array(array('data' => '')); 622 $item['description'] = array(array('data' => '')); 623 } 624 $items[] = array('child' => array('' => $item)); 625 } 626 } 627 // Mimic RSS data format when storing microformats. 628 $link = array(array('data' => $url)); 629 $image = ''; 630 if (!is_string($feed_author) && 631 isset($feed_author['properties']['photo'][0])) { 632 $image = array(array('child' => array('' => array('url' => 633 array(array('data' => $feed_author['properties']['photo'][0])))))); 634 } 635 // Use the name given for the h-feed, or get the title from the html. 636 if ($feed_title !== '') { 637 $feed_title = array(array('data' => htmlspecialchars($feed_title))); 638 } 639 else if ($position = strpos($data, '<title>')) { 640 $start = $position < 200 ? 0 : $position - 200; 641 $check = substr($data, $start, 400); 642 $matches = array(); 643 if (preg_match('/<title>(.+)<\/title>/', $check, $matches)) { 644 $feed_title = array(array('data' => htmlspecialchars($matches[1]))); 645 } 646 } 647 $channel = array('channel' => array(array('child' => array('' => 648 array('link' => $link, 'image' => $image, 'title' => $feed_title, 649 'item' => $items))))); 650 $rss = array(array('attribs' => array('' => array('version' => '2.0')), 651 'child' => array('' => $channel))); 652 $this->data = array('child' => array('' => array('rss' => $rss))); 653 return true; 654 } 655 656 private function declare_html_entities() { 657 // This is required because the RSS specification says that entity-encoded 658 // html is allowed, but the xml specification says they must be declared. 659 return '<!DOCTYPE html [ <!ENTITY nbsp " "> <!ENTITY iexcl "¡"> <!ENTITY cent "¢"> <!ENTITY pound "£"> <!ENTITY curren "¤"> <!ENTITY yen "¥"> <!ENTITY brvbar "¦"> <!ENTITY sect "§"> <!ENTITY uml "¨"> <!ENTITY copy "©"> <!ENTITY ordf "ª"> <!ENTITY laquo "«"> <!ENTITY not "¬"> <!ENTITY shy "­"> <!ENTITY reg "®"> <!ENTITY macr "¯"> <!ENTITY deg "°"> <!ENTITY plusmn "±"> <!ENTITY sup2 "²"> <!ENTITY sup3 "³"> <!ENTITY acute "´"> <!ENTITY micro "µ"> <!ENTITY para "¶"> <!ENTITY middot "·"> <!ENTITY cedil "¸"> <!ENTITY sup1 "¹"> <!ENTITY ordm "º"> <!ENTITY raquo "»"> <!ENTITY frac14 "¼"> <!ENTITY frac12 "½"> <!ENTITY frac34 "¾"> <!ENTITY iquest "¿"> <!ENTITY Agrave "À"> <!ENTITY Aacute "Á"> <!ENTITY Acirc "Â"> <!ENTITY Atilde "Ã"> <!ENTITY Auml "Ä"> <!ENTITY Aring "Å"> <!ENTITY AElig "Æ"> <!ENTITY Ccedil "Ç"> <!ENTITY Egrave "È"> <!ENTITY Eacute "É"> <!ENTITY Ecirc "Ê"> <!ENTITY Euml "Ë"> <!ENTITY Igrave "Ì"> <!ENTITY Iacute "Í"> <!ENTITY Icirc "Î"> <!ENTITY Iuml "Ï"> <!ENTITY ETH "Ð"> <!ENTITY Ntilde "Ñ"> <!ENTITY Ograve "Ò"> <!ENTITY Oacute "Ó"> <!ENTITY Ocirc "Ô"> <!ENTITY Otilde "Õ"> <!ENTITY Ouml "Ö"> <!ENTITY times "×"> <!ENTITY Oslash "Ø"> <!ENTITY Ugrave "Ù"> <!ENTITY Uacute "Ú"> <!ENTITY Ucirc "Û"> <!ENTITY Uuml "Ü"> <!ENTITY Yacute "Ý"> <!ENTITY THORN "Þ"> <!ENTITY szlig "ß"> <!ENTITY agrave "à"> <!ENTITY aacute "á"> <!ENTITY acirc "â"> <!ENTITY atilde "ã"> <!ENTITY auml "ä"> <!ENTITY aring "å"> <!ENTITY aelig "æ"> <!ENTITY ccedil "ç"> <!ENTITY egrave "è"> <!ENTITY eacute "é"> <!ENTITY ecirc "ê"> <!ENTITY euml "ë"> <!ENTITY igrave "ì"> <!ENTITY iacute "í"> <!ENTITY icirc "î"> <!ENTITY iuml "ï"> <!ENTITY eth "ð"> <!ENTITY ntilde "ñ"> <!ENTITY ograve "ò"> <!ENTITY oacute "ó"> <!ENTITY ocirc "ô"> <!ENTITY otilde "õ"> <!ENTITY ouml "ö"> <!ENTITY divide "÷"> <!ENTITY oslash "ø"> <!ENTITY ugrave "ù"> <!ENTITY uacute "ú"> <!ENTITY ucirc "û"> <!ENTITY uuml "ü"> <!ENTITY yacute "ý"> <!ENTITY thorn "þ"> <!ENTITY yuml "ÿ"> <!ENTITY OElig "Œ"> <!ENTITY oelig "œ"> <!ENTITY Scaron "Š"> <!ENTITY scaron "š"> <!ENTITY Yuml "Ÿ"> <!ENTITY fnof "ƒ"> <!ENTITY circ "ˆ"> <!ENTITY tilde "˜"> <!ENTITY Alpha "Α"> <!ENTITY Beta "Β"> <!ENTITY Gamma "Γ"> <!ENTITY Epsilon "Ε"> <!ENTITY Zeta "Ζ"> <!ENTITY Eta "Η"> <!ENTITY Theta "Θ"> <!ENTITY Iota "Ι"> <!ENTITY Kappa "Κ"> <!ENTITY Lambda "Λ"> <!ENTITY Mu "Μ"> <!ENTITY Nu "Ν"> <!ENTITY Xi "Ξ"> <!ENTITY Omicron "Ο"> <!ENTITY Pi "Π"> <!ENTITY Rho "Ρ"> <!ENTITY Sigma "Σ"> <!ENTITY Tau "Τ"> <!ENTITY Upsilon "Υ"> <!ENTITY Phi "Φ"> <!ENTITY Chi "Χ"> <!ENTITY Psi "Ψ"> <!ENTITY Omega "Ω"> <!ENTITY alpha "α"> <!ENTITY beta "β"> <!ENTITY gamma "γ"> <!ENTITY delta "δ"> <!ENTITY epsilon "ε"> <!ENTITY zeta "ζ"> <!ENTITY eta "η"> <!ENTITY theta "θ"> <!ENTITY iota "ι"> <!ENTITY kappa "κ"> <!ENTITY lambda "λ"> <!ENTITY mu "μ"> <!ENTITY nu "ν"> <!ENTITY xi "ξ"> <!ENTITY omicron "ο"> <!ENTITY pi "π"> <!ENTITY rho "ρ"> <!ENTITY sigmaf "ς"> <!ENTITY sigma "σ"> <!ENTITY tau "τ"> <!ENTITY upsilon "υ"> <!ENTITY phi "φ"> <!ENTITY chi "χ"> <!ENTITY psi "ψ"> <!ENTITY omega "ω"> <!ENTITY thetasym "ϑ"> <!ENTITY upsih "ϒ"> <!ENTITY piv "ϖ"> <!ENTITY ensp " "> <!ENTITY emsp " "> <!ENTITY thinsp " "> <!ENTITY zwnj "‌"> <!ENTITY zwj "‍"> <!ENTITY lrm "‎"> <!ENTITY rlm "‏"> <!ENTITY ndash "–"> <!ENTITY mdash "—"> <!ENTITY lsquo "‘"> <!ENTITY rsquo "’"> <!ENTITY sbquo "‚"> <!ENTITY ldquo "“"> <!ENTITY rdquo "”"> <!ENTITY bdquo "„"> <!ENTITY dagger "†"> <!ENTITY Dagger "‡"> <!ENTITY bull "•"> <!ENTITY hellip "…"> <!ENTITY permil "‰"> <!ENTITY prime "′"> <!ENTITY Prime "″"> <!ENTITY lsaquo "‹"> <!ENTITY rsaquo "›"> <!ENTITY oline "‾"> <!ENTITY frasl "⁄"> <!ENTITY euro "€"> <!ENTITY image "ℑ"> <!ENTITY weierp "℘"> <!ENTITY real "ℜ"> <!ENTITY trade "™"> <!ENTITY alefsym "ℵ"> <!ENTITY larr "←"> <!ENTITY uarr "↑"> <!ENTITY rarr "→"> <!ENTITY darr "↓"> <!ENTITY harr "↔"> <!ENTITY crarr "↵"> <!ENTITY lArr "⇐"> <!ENTITY uArr "⇑"> <!ENTITY rArr "⇒"> <!ENTITY dArr "⇓"> <!ENTITY hArr "⇔"> <!ENTITY forall "∀"> <!ENTITY part "∂"> <!ENTITY exist "∃"> <!ENTITY empty "∅"> <!ENTITY nabla "∇"> <!ENTITY isin "∈"> <!ENTITY notin "∉"> <!ENTITY ni "∋"> <!ENTITY prod "∏"> <!ENTITY sum "∑"> <!ENTITY minus "−"> <!ENTITY lowast "∗"> <!ENTITY radic "√"> <!ENTITY prop "∝"> <!ENTITY infin "∞"> <!ENTITY ang "∠"> <!ENTITY and "∧"> <!ENTITY or "∨"> <!ENTITY cap "∩"> <!ENTITY cup "∪"> <!ENTITY int "∫"> <!ENTITY there4 "∴"> <!ENTITY sim "∼"> <!ENTITY cong "≅"> <!ENTITY asymp "≈"> <!ENTITY ne "≠"> <!ENTITY equiv "≡"> <!ENTITY le "≤"> <!ENTITY ge "≥"> <!ENTITY sub "⊂"> <!ENTITY sup "⊃"> <!ENTITY nsub "⊄"> <!ENTITY sube "⊆"> <!ENTITY supe "⊇"> <!ENTITY oplus "⊕"> <!ENTITY otimes "⊗"> <!ENTITY perp "⊥"> <!ENTITY sdot "⋅"> <!ENTITY lceil "⌈"> <!ENTITY rceil "⌉"> <!ENTITY lfloor "⌊"> <!ENTITY rfloor "⌋"> <!ENTITY lang "〈"> <!ENTITY rang "〉"> <!ENTITY loz "◊"> <!ENTITY spades "♠"> <!ENTITY clubs "♣"> <!ENTITY hearts "♥"> <!ENTITY diams "♦"> ]>'; 660 } 407 661 } -
trunk/src/wp-includes/SimplePie/Rating.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 105 104 return $this->scheme; 106 105 } 107 else 108 { 109 return null; 110 } 106 107 return null; 111 108 } 112 109 … … 122 119 return $this->value; 123 120 } 124 else 125 { 126 return null; 127 } 121 122 return null; 128 123 } 129 124 } -
trunk/src/wp-includes/SimplePie/Registry.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 114 113 public function register($type, $class, $legacy = false) 115 114 { 116 if (! is_subclass_of($class, $this->default[$type]))115 if (!@is_subclass_of($class, $this->default[$type])) 117 116 { 118 117 return false; -
trunk/src/wp-includes/SimplePie/Restriction.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 114 113 return $this->relationship; 115 114 } 116 else 117 { 118 return null; 119 } 115 116 return null; 120 117 } 121 118 … … 131 128 return $this->type; 132 129 } 133 else 134 { 135 return null; 136 } 130 131 return null; 137 132 } 138 133 … … 148 143 return $this->value; 149 144 } 150 else 151 { 152 return null; 153 } 145 146 return null; 154 147 } 155 148 } -
trunk/src/wp-includes/SimplePie/Sanitize.php
r25342 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 62 61 var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); 63 62 var $encode_instead_of_strip = false; 64 var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); 63 var $strip_attributes = array('bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); 64 var $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none')); 65 65 var $strip_comments = false; 66 66 var $output_encoding = 'UTF-8'; … … 161 161 } 162 162 163 public function strip_attributes($attribs = array('bgsound', ' class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'))163 public function strip_attributes($attribs = array('bgsound', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')) 164 164 { 165 165 if ($attribs) … … 177 177 { 178 178 $this->strip_attributes = false; 179 } 180 } 181 182 public function add_attributes($attribs = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none'))) 183 { 184 if ($attribs) 185 { 186 if (is_array($attribs)) 187 { 188 $this->add_attributes = $attribs; 189 } 190 else 191 { 192 $this->add_attributes = explode(',', $attribs); 193 } 194 } 195 else 196 { 197 $this->add_attributes = false; 179 198 } 180 199 } … … 250 269 if (!class_exists('DOMDocument')) 251 270 { 252 $this->registry->call('Misc', 'error', array('DOMDocument not found, unable to use sanitizer', E_USER_WARNING, __FILE__, __LINE__)); 253 return ''; 271 throw new SimplePie_Exception('DOMDocument not found, unable to use sanitizer'); 254 272 } 255 273 $document = new DOMDocument(); 256 274 $document->encoding = 'UTF-8'; 275 257 276 $data = $this->preprocess($data, $type); 258 277 … … 261 280 restore_error_handler(); 262 281 282 $xpath = new DOMXPath($document); 283 263 284 // Strip comments 264 285 if ($this->strip_comments) 265 286 { 266 $xpath = new DOMXPath($document);267 287 $comments = $xpath->query('//comment()'); 268 288 … … 280 300 foreach ($this->strip_htmltags as $tag) 281 301 { 282 $this->strip_tag($tag, $document, $ type);302 $this->strip_tag($tag, $document, $xpath, $type); 283 303 } 284 304 } … … 288 308 foreach ($this->strip_attributes as $attrib) 289 309 { 290 $this->strip_attr($attrib, $document); 310 $this->strip_attr($attrib, $xpath); 311 } 312 } 313 314 if ($this->add_attributes) 315 { 316 foreach ($this->add_attributes as $tag => $valuePairs) 317 { 318 $this->add_attr($tag, $valuePairs, $document); 291 319 } 292 320 } … … 327 355 else 328 356 { 329 trigger_error("$this->cache_location is not writ eable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);357 trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); 330 358 } 331 359 } … … 335 363 } 336 364 337 // Remove the DOCTYPE 338 // Seems to cause segfaulting if we don't do this 339 if ($document->firstChild instanceof DOMDocumentType) 340 { 341 $document->removeChild($document->firstChild); 342 } 343 344 // Move everything from the body to the root 345 $real_body = $document->getElementsByTagName('body')->item(0)->childNodes->item(0); 346 $document->replaceChild($real_body, $document->firstChild); 347 365 // Get content node 366 $div = $document->getElementsByTagName('body')->item(0)->firstChild; 348 367 // Finally, convert to a HTML string 349 $data = trim($document->saveHTML( ));368 $data = trim($document->saveHTML($div)); 350 369 351 370 if ($this->remove_div) … … 385 404 { 386 405 $ret = ''; 406 $html = preg_replace('%</?(?:html|body)[^>]*?'.'>%is', '', $html); 387 407 if ($type & ~SIMPLEPIE_CONSTRUCT_XHTML) 388 408 { … … 457 477 } 458 478 459 protected function strip_tag($tag, $document, $type) 460 { 461 $xpath = new DOMXPath($document); 479 protected function strip_tag($tag, $document, $xpath, $type) 480 { 462 481 $elements = $xpath->query('body//' . $tag); 463 482 if ($this->encode_instead_of_strip) … … 542 561 } 543 562 544 protected function strip_attr($attrib, $document) 545 { 546 $xpath = new DOMXPath($document); 563 protected function strip_attr($attrib, $xpath) 564 { 547 565 $elements = $xpath->query('//*[@' . $attrib . ']'); 548 566 … … 552 570 } 553 571 } 572 573 protected function add_attr($tag, $valuePairs, $document) 574 { 575 $elements = $document->getElementsByTagName($tag); 576 foreach ($elements as $element) 577 { 578 foreach ($valuePairs as $attrib => $value) 579 { 580 $element->setAttribute($attrib, $value); 581 } 582 } 583 } 554 584 } -
trunk/src/wp-includes/SimplePie/Source.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 81 80 return $this->data['child'][$namespace][$tag]; 82 81 } 83 else 84 { 85 return null; 86 } 82 83 return null; 87 84 } 88 85 … … 132 129 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 133 130 } 134 else 135 { 136 return null; 137 } 131 132 return null; 138 133 } 139 134 … … 145 140 return $categories[$key]; 146 141 } 147 else 148 { 149 return null; 150 } 142 143 return null; 151 144 } 152 145 … … 202 195 return array_unique($categories); 203 196 } 204 else 205 { 206 return null; 207 } 197 198 return null; 208 199 } 209 200 … … 215 206 return $authors[$key]; 216 207 } 217 else 218 { 219 return null; 220 } 208 209 return null; 221 210 } 222 211 … … 285 274 return array_unique($authors); 286 275 } 287 else 288 { 289 return null; 290 } 276 277 return null; 291 278 } 292 279 … … 298 285 return $contributors[$key]; 299 286 } 300 else 301 { 302 return null; 303 } 287 288 return null; 304 289 } 305 290 … … 356 341 return array_unique($contributors); 357 342 } 358 else 359 { 360 return null; 361 } 343 344 return null; 362 345 } 363 346 … … 369 352 return $links[$key]; 370 353 } 371 else 372 { 373 return null; 374 } 354 355 return null; 375 356 } 376 357 … … 451 432 return $this->data['links'][$rel]; 452 433 } 453 else 454 { 455 return null; 456 } 434 435 return null; 457 436 } 458 437 … … 495 474 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 496 475 } 497 else 498 { 499 return null; 500 } 476 477 return null; 501 478 } 502 479 … … 523 500 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 524 501 } 525 else 526 { 527 return null; 528 } 502 503 return null; 529 504 } 530 505 … … 547 522 return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); 548 523 } 549 else 550 { 551 return null; 552 } 524 525 return null; 553 526 } 554 527 … … 563 536 return (float) $match[1]; 564 537 } 565 else 566 { 567 return null; 568 } 538 539 return null; 569 540 } 570 541 … … 583 554 return (float) $match[2]; 584 555 } 585 else 586 { 587 return null; 588 } 556 557 return null; 589 558 } 590 559 … … 603 572 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 604 573 } 605 else 606 { 607 return null; 608 } 574 575 return null; 609 576 } 610 577 } 611 -
trunk/src/wp-includes/SimplePie/XML/Declaration/Parser.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 138 137 return true; 139 138 } 140 else 141 { 142 $this->version = ''; 143 $this->encoding = ''; 144 $this->standalone = ''; 145 return false; 146 } 139 140 $this->version = ''; 141 $this->encoding = ''; 142 $this->standalone = ''; 143 return false; 147 144 } 148 145 -
trunk/src/wp-includes/SimplePie/gzdecode.php
r22798 r47733 6 6 * Takes the hard work out of managing a complete RSS/Atom solution. 7 7 * 8 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 9 9 * All rights reserved. 10 10 * … … 34 34 * 35 35 * @package SimplePie 36 * @version 1.3.1 37 * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue 36 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 38 37 * @author Ryan Parman 39 * @author GeoffreySneddon38 * @author Sam Sneddon 40 39 * @author Ryan McCue 41 40 * @link http://simplepie.org/ SimplePie … … 340 339 return false; 341 340 } 342 else 343 { 344 $this->position = $this->compressed_size - 8; 345 } 341 342 $this->position = $this->compressed_size - 8; 346 343 347 344 // Check CRC of data … … 364 361 return true; 365 362 } 366 else 367 { 368 return false; 369 } 363 364 return false; 370 365 } 371 366 } -
trunk/src/wp-includes/class-simplepie.php
r47198 r47733 41 41 * Takes the hard work out of managing a complete RSS/Atom solution. 42 42 * 43 * Copyright (c) 2004-201 2, Ryan Parman, GeoffreySneddon, Ryan McCue, and contributors43 * Copyright (c) 2004-2017, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 44 44 * All rights reserved. 45 45 * … … 69 69 * 70 70 * @package SimplePie 71 * @version 1. 3.172 * @copyright 2004-201 2 Ryan Parman, GeoffreySneddon, Ryan McCue71 * @version 1.5.5 72 * @copyright 2004-2017 Ryan Parman, Sam Sneddon, Ryan McCue 73 73 * @author Ryan Parman 74 * @author GeoffreySneddon74 * @author Sam Sneddon 75 75 * @author Ryan McCue 76 76 * @link http://simplepie.org/ SimplePie … … 86 86 * SimplePie Version 87 87 */ 88 define('SIMPLEPIE_VERSION', '1. 3.1');88 define('SIMPLEPIE_VERSION', '1.5.5'); 89 89 90 90 /** … … 482 482 483 483 /** 484 * @var string Original feed URL, or new feed URL iff HTTP 301 Moved Permanently 485 * @see SimplePie::subscribe_url() 486 * @access private 487 */ 488 public $permanent_url = null; 489 490 /** 484 491 * @var object Instance of SimplePie_File to use as a feed 485 492 * @see SimplePie::set_file() … … 501 508 */ 502 509 public $timeout = 10; 510 511 /** 512 * @var array Custom curl options 513 * @see SimplePie::set_curl_options() 514 * @access private 515 */ 516 public $curl_options = array(); 503 517 504 518 /** … … 526 540 527 541 /** 542 * @var bool Force SimplePie to fallback to expired cache, if enabled, 543 * when feed is unavailable. 544 * @see SimplePie::force_cache_fallback() 545 * @access private 546 */ 547 public $force_cache_fallback = false; 548 549 /** 528 550 * @var int Cache duration (in seconds) 529 551 * @see SimplePie::set_cache_duration() … … 631 653 632 654 /** 655 * @var bool Stores if last-modified and/or etag headers were sent with the 656 * request when checking a feed. 657 */ 658 public $check_modified = false; 659 660 /** 633 661 * @var array Stores the default attributes to be stripped by strip_attributes(). 634 662 * @see SimplePie::strip_attributes() … … 638 666 639 667 /** 668 * @var array Stores the default attributes to add to different tags by add_attributes(). 669 * @see SimplePie::add_attributes() 670 * @access private 671 */ 672 public $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none')); 673 674 /** 640 675 * @var array Stores the default tags to be stripped by strip_htmltags(). 641 676 * @see SimplePie::strip_htmltags() … … 643 678 */ 644 679 public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); 680 681 /** 682 * @var bool Should we throw exceptions, or use the old-style error property? 683 * @access private 684 */ 685 public $enable_exceptions = false; 645 686 646 687 /** … … 660 701 public function __construct() 661 702 { 662 if (version_compare(PHP_VERSION, '5. 2', '<'))663 { 664 trigger_error('P HP 4.x, 5.0 and 5.1 are no longer supported. Please upgrade to PHP 5.2or newer.');703 if (version_compare(PHP_VERSION, '5.6', '<')) 704 { 705 trigger_error('Please upgrade to PHP 5.6 or newer.'); 665 706 die(); 666 707 } … … 673 714 { 674 715 $level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING; 675 trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_ location() directly.', $level);716 trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_duration() directly.', $level); 676 717 677 718 $args = func_get_args(); … … 701 742 public function __destruct() 702 743 { 703 if ( (version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))744 if (!gc_enabled()) 704 745 { 705 746 if (!empty($this->data['items'])) … … 764 805 { 765 806 $this->feed_url = $this->registry->call('Misc', 'fix_protocol', array($url, 1)); 807 $this->permanent_url = $this->feed_url; 766 808 } 767 809 } … … 778 820 { 779 821 $this->feed_url = $file->url; 822 $this->permanent_url = $this->feed_url; 780 823 $this->file =& $file; 781 824 return true; … … 803 846 804 847 /** 805 * Set the thedefault timeout for fetching remote feeds848 * Set the default timeout for fetching remote feeds 806 849 * 807 850 * This allows you to change the maximum time the feed's server to respond … … 817 860 818 861 /** 862 * Set custom curl options 863 * 864 * This allows you to change default curl options 865 * 866 * @since 1.0 Beta 3 867 * @param array $curl_options Curl options to add to default settings 868 */ 869 public function set_curl_options(array $curl_options = array()) 870 { 871 $this->curl_options = $curl_options; 872 } 873 874 /** 819 875 * Force SimplePie to use fsockopen() instead of cURL 820 876 * … … 839 895 { 840 896 $this->cache = (bool) $enable; 897 } 898 899 /** 900 * SimplePie to continue to fall back to expired cache, if enabled, when 901 * feed is unavailable. 902 * 903 * This tells SimplePie to ignore any file errors and fall back to cache 904 * instead. This only works if caching is enabled and cached content 905 * still exists. 906 907 * @param bool $enable Force use of cache on fail. 908 */ 909 public function force_cache_fallback($enable = false) 910 { 911 $this->force_cache_fallback= (bool) $enable; 841 912 } 842 913 … … 1109 1180 $this->strip_htmltags(false); 1110 1181 $this->strip_attributes(false); 1182 $this->add_attributes(false); 1111 1183 $this->set_image_handler(false); 1112 1184 } … … 1155 1227 } 1156 1228 1229 public function add_attributes($attribs = '') 1230 { 1231 if ($attribs === '') 1232 { 1233 $attribs = $this->add_attributes; 1234 } 1235 $this->sanitize->add_attributes($attribs); 1236 } 1237 1157 1238 /** 1158 1239 * Set the output encoding … … 1160 1241 * Allows you to override SimplePie's output to match that of your webpage. 1161 1242 * This is useful for times when your webpages are not being served as 1162 * UTF-8. 1243 * UTF-8. This setting will be obeyed by {@see handle_content_type()}, and 1163 1244 * is similar to {@see set_input_encoding()}. 1164 1245 * 1165 1246 * It should be noted, however, that not all character encodings can support 1166 * all characters. 1247 * all characters. If your page is being served as ISO-8859-1 and you try 1167 1248 * to display a Japanese feed, you'll likely see garbled characters. 1168 1249 * Because of this, it is highly recommended to ensure that your webpages … … 1206 1287 * Set the handler to enable the display of cached images. 1207 1288 * 1208 * @param str $page Web-accessible path to the handler_image.php file.1209 * @param str $qs The query string that the value should be passed to.1289 * @param string $page Web-accessible path to the handler_image.php file. 1290 * @param string $qs The query string that the value should be passed to. 1210 1291 */ 1211 1292 public function set_image_handler($page = false, $qs = 'i') … … 1232 1313 1233 1314 /** 1315 * Enable throwing exceptions 1316 * 1317 * @param boolean $enable Should we throw exceptions, or use the old-style error property? 1318 */ 1319 public function enable_exceptions($enable = true) 1320 { 1321 $this->enable_exceptions = $enable; 1322 } 1323 1324 /** 1234 1325 * Initialize the feed object 1235 1326 * 1236 * This is what makes everything happen. Period.This is where all of the1327 * This is what makes everything happen. Period. This is where all of the 1237 1328 * configuration options get processed, feeds are fetched, cached, and 1238 1329 * parsed, and all of that other good stuff. … … 1245 1336 if (!extension_loaded('xml') || !extension_loaded('pcre')) 1246 1337 { 1338 $this->error = 'XML or PCRE extensions not loaded!'; 1247 1339 return false; 1248 1340 } … … 1264 1356 } 1265 1357 1358 // The default sanitize class gets set in the constructor, check if it has 1359 // changed. 1360 if ($this->registry->get_class('Sanitize') !== 'SimplePie_Sanitize') { 1361 $this->sanitize = $this->registry->create('Sanitize'); 1362 } 1266 1363 if (method_exists($this->sanitize, 'set_registry')) 1267 1364 { … … 1272 1369 // Pass the classes in for legacy support; new classes should use the registry instead 1273 1370 $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->registry->get_class('Cache')); 1274 $this->sanitize->pass_file_data($this->registry->get_class('File'), $this->timeout, $this->useragent, $this->force_fsockopen );1371 $this->sanitize->pass_file_data($this->registry->get_class('File'), $this->timeout, $this->useragent, $this->force_fsockopen, $this->curl_options); 1275 1372 1276 1373 if (!empty($this->multifeed_url)) … … 1301 1398 $this->error = null; 1302 1399 $this->data = array(); 1400 $this->check_modified = false; 1303 1401 $this->multifeed_objects = array(); 1304 1402 $cache = false; … … 1311 1409 if ($this->cache && $parsed_feed_url['scheme'] !== '') 1312 1410 { 1313 $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc')); 1411 $url = $this->feed_url . ($this->force_feed ? '#force_feed' : ''); 1412 $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $url), 'spc')); 1314 1413 } 1315 1414 … … 1326 1425 } 1327 1426 1427 // Empty response check 1428 if(empty($this->raw_data)){ 1429 $this->error = "A feed could not be found at `$this->feed_url`. Empty body."; 1430 $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); 1431 return false; 1432 } 1433 1328 1434 // Set up array of possible encodings 1329 1435 $encodings = array(); … … 1332 1438 if ($this->input_encoding !== false) 1333 1439 { 1334 $encodings[] = $this->input_encoding;1440 $encodings[] = strtoupper($this->input_encoding); 1335 1441 } 1336 1442 … … 1354 1460 if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) 1355 1461 { 1356 $encodings[] = $charset[1];1462 $encodings[] = strtoupper($charset[1]); 1357 1463 } 1358 1464 $encodings[] = 'US-ASCII'; … … 1361 1467 elseif (substr($sniffed, 0, 5) === 'text/') 1362 1468 { 1363 $encodings[] = 'U S-ASCII';1469 $encodings[] = 'UTF-8'; 1364 1470 } 1365 1471 } … … 1383 1489 1384 1490 // If it's parsed fine 1385 if ($parser->parse($utf8_data, 'UTF-8' ))1491 if ($parser->parse($utf8_data, 'UTF-8', $this->permanent_url)) 1386 1492 { 1387 1493 $this->data = $parser->get_data(); 1388 1494 if (!($this->get_type() & ~SIMPLEPIE_TYPE_NONE)) 1389 1495 { 1390 $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed.";1496 $this->error = "A feed could not be found at `$this->feed_url`. This does not appear to be a valid RSS or Atom feed."; 1391 1497 $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); 1392 1498 return false; … … 1402 1508 if ($cache && !$cache->save($this)) 1403 1509 { 1404 trigger_error("$this->cache_location is not writ eable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);1510 trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); 1405 1511 } 1406 1512 return true; … … 1412 1518 { 1413 1519 // We have an error, just set SimplePie_Misc::error to it and quit 1414 $this->error = sprintf('This XML document is invalid, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); 1520 $this->error = $this->feed_url; 1521 $this->error .= sprintf(' is invalid XML, likely due to invalid characters. XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); 1415 1522 } 1416 1523 else 1417 1524 { 1418 $this->error = 'The data could not be converted to UTF-8. You MUST have either the iconv or mbstring extension installed. Upgrading to PHP 5.x (which includes iconv) is highly recommended.'; 1525 $this->error = 'The data could not be converted to UTF-8.'; 1526 if (!extension_loaded('mbstring') && !extension_loaded('iconv') && !class_exists('\UConverter')) { 1527 $this->error .= ' You MUST have either the iconv, mbstring or intl (PHP 5.5+) extension installed and enabled.'; 1528 } else { 1529 $missingExtensions = array(); 1530 if (!extension_loaded('iconv')) { 1531 $missingExtensions[] = 'iconv'; 1532 } 1533 if (!extension_loaded('mbstring')) { 1534 $missingExtensions[] = 'mbstring'; 1535 } 1536 if (!class_exists('\UConverter')) { 1537 $missingExtensions[] = 'intl (PHP 5.5+)'; 1538 } 1539 $this->error .= ' Try installing/enabling the ' . implode(' or ', $missingExtensions) . ' extension.'; 1540 } 1419 1541 } 1420 1542 … … 1472 1594 elseif ($cache->mtime() + $this->cache_duration < time()) 1473 1595 { 1474 // If we have last-modified and/or etag set 1596 // Want to know if we tried to send last-modified and/or etag headers 1597 // when requesting this file. (Note that it's up to the file to 1598 // support this, but we don't always send the headers either.) 1599 $this->check_modified = true; 1475 1600 if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) 1476 1601 { … … 1487 1612 } 1488 1613 1489 $file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen ));1614 $file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options)); 1490 1615 1491 1616 if ($file->success) … … 1493 1618 if ($file->status_code === 304) 1494 1619 { 1620 // Set raw_data to false here too, to signify that the cache 1621 // is still valid. 1622 $this->raw_data = false; 1495 1623 $cache->touch(); 1496 1624 return true; … … 1499 1627 else 1500 1628 { 1629 $this->check_modified = false; 1630 if($this->force_cache_fallback) 1631 { 1632 $cache->touch(); 1633 return true; 1634 } 1635 1501 1636 unset($file); 1502 1637 } … … 1529 1664 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1', 1530 1665 ); 1531 $file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen ));1666 $file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options)); 1532 1667 } 1533 1668 } … … 1542 1677 { 1543 1678 // Check if the supplied URL is a feed, if it isn't, look for it. 1544 $locate = $this->registry->create('Locator', array(&$file, $this->timeout, $this->useragent, $this->max_checked_feeds ));1679 $locate = $this->registry->create('Locator', array(&$file, $this->timeout, $this->useragent, $this->max_checked_feeds, $this->force_fsockopen, $this->curl_options)); 1545 1680 1546 1681 if (!$locate->is_feed($file)) 1547 1682 { 1548 // We need to unset this so that if SimplePie::set_file() has been called that object is untouched1549 unset($file);1683 $copyStatusCode = $file->status_code; 1684 $copyContentType = $file->headers['content-type']; 1550 1685 try 1551 1686 { 1552 if (!($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds))) 1687 $microformats = false; 1688 if (class_exists('DOMXpath') && function_exists('Mf2\parse')) { 1689 $doc = new DOMDocument(); 1690 @$doc->loadHTML($file->body); 1691 $xpath = new DOMXpath($doc); 1692 // Check for both h-feed and h-entry, as both a feed with no entries 1693 // and a list of entries without an h-feed wrapper are both valid. 1694 $query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '. 1695 'contains(concat(" ", @class, " "), " h-entry ")]'; 1696 $result = $xpath->query($query); 1697 $microformats = $result->length !== 0; 1698 } 1699 // Now also do feed discovery, but if microformats were found don't 1700 // overwrite the current value of file. 1701 $discovered = $locate->find($this->autodiscovery, 1702 $this->all_discovered_feeds); 1703 if ($microformats) 1553 1704 { 1554 $this->error = "A feed could not be found at $this->feed_url. A feed with an invalid mime type may fall victim to this error, or " . SIMPLEPIE_NAME . " was unable to auto-discover it.. Use force_feed() if you are certain this URL is a real feed."; 1555 $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); 1556 return false; 1705 if ($hub = $locate->get_rel_link('hub')) 1706 { 1707 $self = $locate->get_rel_link('self'); 1708 $this->store_links($file, $hub, $self); 1709 } 1710