Make WordPress Core

Changeset 47733


Ignore:
Timestamp:
05/01/2020 02:24:42 PM (6 years ago)
Author:
desrosj
Message:

External Libraries: Update the SimplePie library to the latest version (1.5.5).

This brings SimplePie in sync with the most up to date version, 1.5.5.

This update brings many bug fixes, small enhancements, and PHP compatibility fixes for newer versions of PHP.

For a full list of changes, see https://github.com/simplepie/simplepie/blob/master/CHANGELOG.md#155-may-1-2020.

Props dshanske, slushman, etruel, wpshades, dmenard, desrosj, hareesh-pillai, stevenkword, jrf, Ipstenu, johnbillion.
Fixes #36669.

Location:
trunk/src/wp-includes
Files:
2 added
33 edited

Legend:

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

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    115114                        return $this->name;
    116115                }
    117                 else
    118                 {
    119                         return null;
    120                 }
     116
     117                return null;
    121118        }
    122119
     
    132129                        return $this->link;
    133130                }
    134                 else
    135                 {
    136                         return null;
    137                 }
     131
     132                return null;
    138133        }
    139134
     
    149144                        return $this->email;
    150145                }
    151                 else
    152                 {
    153                         return null;
    154                 }
     146
     147                return null;
    155148        }
    156149}
    157 
  • trunk/src/wp-includes/SimplePie/Cache.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    6362         */
    6463        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'
    6768        );
    6869
  • trunk/src/wp-includes/SimplePie/Cache/Base.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
  • trunk/src/wp-includes/SimplePie/Cache/DB.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
  • trunk/src/wp-includes/SimplePie/Cache/File.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    103102        public function save($data)
    104103        {
    105                 if (file_exists($this->name) && is_writeable($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))
    106105                {
    107106                        if ($data instanceof SimplePie)
     
    137136        public function mtime()
    138137        {
    139                 if (file_exists($this->name))
    140                 {
    141                         return filemtime($this->name);
    142                 }
    143                 return false;
     138                return @filemtime($this->name);
    144139        }
    145140
     
    151146        public function touch()
    152147        {
    153                 if (file_exists($this->name))
    154                 {
    155                         return touch($this->name);
    156                 }
    157                 return false;
     148                return @touch($this->name);
    158149        }
    159150
  • trunk/src/wp-includes/SimplePie/Cache/Memcache.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    9695                        ),
    9796                );
    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
    10299                $this->name = $this->options['extras']['prefix'] . md5("$name:$type");
    103100
     
    148145                if ($data !== false)
    149146                {
    150                         // essentially ignore the mtime because Memcache expires on it's own
     147                        // essentially ignore the mtime because Memcache expires on its own
    151148                        return time();
    152149                }
     
    166163                if ($data !== false)
    167164                {
    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']);
    169166                }
    170167
  • trunk/src/wp-includes/SimplePie/Cache/MySQL.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    9594                        'extras' => array(
    9695                                'prefix' => '',
     96                                'cache_purge_time' => 2592000
    9797                        ),
    9898                );
    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));
    100101
    101102                // Path is prefixed with a "/"
     
    131132                        if ($query === false)
    132133                        {
     134                                trigger_error("Can't create " . $this->options['extras']['prefix'] . "cache_data table, check permissions", E_USER_WARNING);
    133135                                $this->mysql = null;
     136                                return;
    134137                        }
    135138                }
     
    137140                if (!in_array($this->options['extras']['prefix'] . 'items', $db))
    138141                {
    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 utf8 NOT 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)))');
    140143                        if ($query === false)
    141144                        {
     145                                trigger_error("Can't create " . $this->options['extras']['prefix'] . "items table, check permissions", E_USER_WARNING);
    142146                                $this->mysql = null;
     147                                return;
    143148                        }
    144149                }
     
    154159        {
    155160                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())
    156172                {
    157173                        return false;
     
    380396                        return $time;
    381397                }
    382                 else
    383                 {
    384                         return false;
    385                 }
     398
     399                return false;
    386400        }
    387401
     
    401415                $query->bindValue(':time', time());
    402416                $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;
    411419        }
    412420
     
    427435                $query2 = $this->mysql->prepare('DELETE FROM `' . $this->options['extras']['prefix'] . 'items` WHERE `feed_id` = :id');
    428436                $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();
    437439        }
    438440}
  • trunk/src/wp-includes/SimplePie/Caption.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    133132                        return $this->endTime;
    134133                }
    135                 else
    136                 {
    137                         return null;
    138                 }
     134
     135                return null;
    139136        }
    140137
     
    151148                        return $this->lang;
    152149                }
    153                 else
    154                 {
    155                         return null;
    156                 }
     150
     151                return null;
    157152        }
    158153
     
    168163                        return $this->startTime;
    169164                }
    170                 else
    171                 {
    172                         return null;
    173                 }
     165
     166                return null;
    174167        }
    175168
     
    185178                        return $this->text;
    186179                }
    187                 else
    188                 {
    189                         return null;
    190                 }
     180
     181                return null;
    191182        }
    192183
     
    202193                        return $this->type;
    203194                }
    204                 else
    205                 {
    206                         return null;
    207                 }
     195
     196                return null;
    208197        }
    209198}
    210 
  • trunk/src/wp-includes/SimplePie/Category.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    5857         * Category identifier
    5958         *
    60          * @var string
     59         * @var string|null
    6160         * @see get_term
    6261         */
     
    6665         * Categorization scheme identifier
    6766         *
    68          * @var string
     67         * @var string|null
    6968         * @see get_scheme()
    7069         */
     
    7473         * Human readable label
    7574         *
    76          * @var string
     75         * @var string|null
    7776         * @see get_label()
    7877         */
     
    8079
    8180        /**
     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        /**
    8292         * Constructor, used to input the data
    8393         *
    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
    8798         */
    88         public function __construct($term = null, $scheme = null, $label = null)
     99        public function __construct($term = null, $scheme = null, $label = null, $type = null)
    89100        {
    90101                $this->term = $term;
    91102                $this->scheme = $scheme;
    92103                $this->label = $label;
     104                $this->type = $type;
    93105        }
    94106
     
    111123        public function get_term()
    112124        {
    113                 if ($this->term !== null)
    114                 {
    115                         return $this->term;
    116                 }
    117                 else
    118                 {
    119                         return null;
    120                 }
     125                return $this->term;
    121126        }
    122127
     
    128133        public function get_scheme()
    129134        {
    130                 if ($this->scheme !== null)
    131                 {
    132                         return $this->scheme;
    133                 }
    134                 else
    135                 {
    136                         return null;
    137                 }
     135                return $this->scheme;
    138136        }
    139137
     
    141139         * Get the human readable label
    142140         *
     141         * @param bool $strict
    143142         * @return string|null
    144143         */
    145         public function get_label()
     144        public function get_label($strict = false)
    146145        {
    147                 if ($this->label !== null)
    148                 {
    149                         return $this->label;
    150                 }
    151                 else
     146                if ($this->label === null && $strict !== true)
    152147                {
    153148                        return $this->get_term();
    154149                }
     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;
    155161        }
    156162}
  • trunk/src/wp-includes/SimplePie/Content/Type/Sniffer.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    122121                                        return $return;
    123122                                }
    124                                 else
    125                                 {
    126                                         return $official;
    127                                 }
     123
     124                                return $official;
    128125                        }
    129126                        elseif ($official === 'text/html')
     
    131128                                return $this->feed_or_html();
    132129                        }
    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();
    142135        }
    143136
     
    160153                        return 'application/octect-stream';
    161154                }
    162                 else
    163                 {
    164                         return 'text/plain';
    165                 }
     155
     156                return 'text/plain';
    166157        }
    167158
     
    209200                        return 'image/vnd.microsoft.icon';
    210201                }
    211                 else
    212                 {
    213                         return $this->text_or_binary();
    214                 }
     202
     203                return $this->text_or_binary();
    215204        }
    216205
     
    243232                        return 'image/vnd.microsoft.icon';
    244233                }
    245                 else
    246                 {
    247                         return false;
    248                 }
     234
     235                return false;
    249236        }
    250237
     
    257244        {
    258245                $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");
    260247
    261248                while ($pos < $len)
     
    330317        }
    331318}
    332 
  • trunk/src/wp-includes/SimplePie/Copyright.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    105104                        return $this->url;
    106105                }
    107                 else
    108                 {
    109                         return null;
    110                 }
     106
     107                return null;
    111108        }
    112109
     
    122119                        return $this->label;
    123120                }
    124                 else
    125                 {
    126                         return null;
    127                 }
     121
     122                return null;
    128123        }
    129124}
    130 
  • trunk/src/wp-includes/SimplePie/Core.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2009, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
  • trunk/src/wp-includes/SimplePie/Credit.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    114113                        return $this->role;
    115114                }
    116                 else
    117                 {
    118                         return null;
    119                 }
     115
     116                return null;
    120117        }
    121118
     
    131128                        return $this->scheme;
    132129                }
    133                 else
    134                 {
    135                         return null;
    136                 }
     130
     131                return null;
    137132        }
    138133
     
    148143                        return $this->name;
    149144                }
    150                 else
    151                 {
    152                         return null;
    153                 }
     145
     146                return null;
    154147        }
    155148}
    156 
  • trunk/src/wp-includes/SimplePie/Decode/HTML/Entities.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    119118                        return $this->data[$this->position++];
    120119                }
    121                 else
    122                 {
    123                         return false;
    124                 }
     120
     121                return false;
    125122        }
    126123
     
    141138                        return $data;
    142139                }
    143                 else
    144                 {
    145                         return false;
    146                 }
     140
     141                return false;
    147142        }
    148143
     
    169164                        case "\x09":
    170165                        case "\x0A":
    171                         case "\x0B":
    172166                        case "\x0B":
    173167                        case "\x0C":
     
    615609        }
    616610}
    617 
  • trunk/src/wp-includes/SimplePie/Enclosure.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    284283                        return $this->bitrate;
    285284                }
    286                 else
    287                 {
    288                         return null;
    289                 }
     285
     286                return null;
    290287        }
    291288
     
    303300                        return $captions[$key];
    304301                }
    305                 else
    306                 {
    307                         return null;
    308                 }
     302
     303                return null;
    309304        }
    310305
     
    320315                        return $this->captions;
    321316                }
    322                 else
    323                 {
    324                         return null;
    325                 }
     317
     318                return null;
    326319        }
    327320
     
    339332                        return $categories[$key];
    340333                }
    341                 else
    342                 {
    343                         return null;
    344                 }
     334
     335                return null;
    345336        }
    346337
     
    356347                        return $this->categories;
    357348                }
    358                 else
    359                 {
    360                         return null;
    361                 }
     349
     350                return null;
    362351        }
    363352
     
    373362                        return $this->channels;
    374363                }
    375                 else
    376                 {
    377                         return null;
    378                 }
     364
     365                return null;
    379366        }
    380367
     
    390377                        return $this->copyright;
    391378                }
    392                 else
    393                 {
    394                         return null;
    395                 }
     379
     380                return null;
    396381        }
    397382
     
    409394                        return $credits[$key];
    410395                }
    411                 else
    412                 {
    413                         return null;
    414                 }
     396
     397                return null;
    415398        }
    416399
     
    426409                        return $this->credits;
    427410                }
    428                 else
    429                 {
    430                         return null;
    431                 }
     411
     412                return null;
    432413        }
    433414
     
    443424                        return $this->description;
    444425                }
    445                 else
    446                 {
    447                         return null;
    448                 }
     426
     427                return null;
    449428        }
    450429
     
    452431         * Get the duration of the enclosure
    453432         *
    454          * @param string $convert Convert seconds into hh:mm:ss
     433         * @param bool $convert Convert seconds into hh:mm:ss
    455434         * @return string|int|null 'hh:mm:ss' string if `$convert` was specified, otherwise integer (or null if none found)
    456435         */
     
    464443                                return $time;
    465444                        }
    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;
    475450        }
    476451
     
    486461                        return $this->expression;
    487462                }
    488                 else
    489                 {
    490                         return 'full';
    491                 }
     463
     464                return 'full';
    492465        }
    493466
     
    521494                        return $this->framerate;
    522495                }
    523                 else
    524                 {
    525                         return null;
    526                 }
     496
     497                return null;
    527498        }
    528499
     
    551522                        return $hashes[$key];
    552523                }
    553                 else
    554                 {
    555                         return null;
    556                 }
     524
     525                return null;
    557526        }
    558527
     
    568537                        return $this->hashes;
    569538                }
    570                 else
    571                 {
    572                         return null;
    573                 }
     539
     540                return null;
    574541        }
    575542
     
    585552                        return $this->height;
    586553                }
    587                 else
    588                 {
    589                         return null;
    590                 }
     554
     555                return null;
    591556        }
    592557
     
    603568                        return $this->lang;
    604569                }
    605                 else
    606                 {
    607                         return null;
    608                 }
     570
     571                return null;
    609572        }
    610573
     
    622585                        return $keywords[$key];
    623586                }
    624                 else
    625                 {
    626                         return null;
    627                 }
     587
     588                return null;
    628589        }
    629590
     
    639600                        return $this->keywords;
    640601                }
    641                 else
    642                 {
    643                         return null;
    644                 }
     602
     603                return null;
    645604        }
    646605
     
    656615                        return $this->length;
    657616                }
    658                 else
    659                 {
    660                         return null;
    661                 }
     617
     618                return null;
    662619        }
    663620
     
    673630                        return urldecode($this->link);
    674631                }
    675                 else
    676                 {
    677                         return null;
    678                 }
     632
     633                return null;
    679634        }
    680635
     
    691646                        return $this->medium;
    692647                }
    693                 else
    694                 {
    695                         return null;
    696                 }
     648
     649                return null;
    697650        }
    698651
     
    709662                        return $this->player;
    710663                }
    711                 else
    712                 {
    713                         return null;
    714                 }
     664
     665                return null;
    715666        }
    716667
     
    728679                        return $ratings[$key];
    729680                }
    730                 else
    731                 {
    732                         return null;
    733                 }
     681
     682                return null;
    734683        }
    735684
     
    745694                        return $this->ratings;
    746695                }
    747                 else
    748                 {
    749                         return null;
    750                 }
     696
     697                return null;
    751698        }
    752699
     
    764711                        return $restrictions[$key];
    765712                }
    766                 else
    767                 {
    768                         return null;
    769                 }
     713
     714                return null;
    770715        }
    771716
     
    781726                        return $this->restrictions;
    782727                }
    783                 else
    784                 {
    785                         return null;
    786                 }
     728
     729                return null;
    787730        }
    788731
     
    798741                        return $this->samplingrate;
    799742                }
    800                 else
    801                 {
    802                         return null;
    803                 }
     743
     744                return null;
    804745        }
    805746
     
    816757                        return round($length/1048576, 2);
    817758                }
    818                 else
    819                 {
    820                         return null;
    821                 }
     759
     760                return null;
    822761        }
    823762
     
    835774                        return $thumbnails[$key];
    836775                }
    837                 else
    838                 {
    839                         return null;
    840                 }
     776
     777                return null;
    841778        }
    842779
     
    852789                        return $this->thumbnails;
    853790                }
    854                 else
    855                 {
    856                         return null;
    857                 }
     791
     792                return null;
    858793        }
    859794
     
    869804                        return $this->title;
    870805                }
    871                 else
    872                 {
    873                         return null;
    874                 }
     806
     807                return null;
    875808        }
    876809
     
    887820                        return $this->type;
    888821                }
    889                 else
    890                 {
    891                         return null;
    892                 }
     822
     823                return null;
    893824        }
    894825
     
    904835                        return $this->width;
    905836                }
    906                 else
    907                 {
    908                         return null;
    909                 }
     837
     838                return null;
    910839        }
    911840
     
    943872         *    numeric pixel value (such as `360`) or `auto`. Defaults to `auto`,
    944873         *    and it is recommended that you use this default.
    945          * - `loop` (boolean): Do you want the media to loop when its done?
     874         * - `loop` (boolean): Do you want the media to loop when it's done?
    946875         *    Defaults to `false`.
    947876         * - `mediaplayer` (string): The location of the included
     
    13671296                                return 'mp3';
    13681297                        }
    1369                         else
    1370                         {
    1371                                 return null;
    1372                         }
    1373                 }
    1374                 else
    1375                 {
    1376                         return $type;
    1377                 }
     1298
     1299                        return null;
     1300                }
     1301
     1302                return $type;
    13781303        }
    13791304}
    1380 
  • trunk/src/wp-includes/SimplePie/Exception.php

    r22469 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
  • trunk/src/wp-includes/SimplePie/File.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    6564        var $error;
    6665        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())
    6969        {
    7070                if (class_exists('idna_convert'))
     
    7272                        $idn = new idna_convert();
    7373                        $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);
    7575                }
    7676                $this->url = $url;
     77                $this->permanent_url = $url;
    7778                $this->useragent = $useragent;
    7879                if (preg_match('/^http(s)?:\/\//i', $url))
     
    103104                                curl_setopt($fp, CURLOPT_HEADER, 1);
    104105                                curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
     106                                curl_setopt($fp, CURLOPT_FAILONERROR, 1);
    105107                                curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
    106108                                curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
     
    108110                                curl_setopt($fp, CURLOPT_USERAGENT, $useragent);
    109111                                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', '>='))
    111113                                {
    112114                                        curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
    113115                                        curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
    114116                                }
     117                                foreach ($curl_options as $curl_param => $curl_value) {
     118                                        curl_setopt($fp, $curl_param, $curl_value);
     119                                }
    115120
    116121                                $this->headers = curl_exec($fp);
     
    127132                                else
    128133                                {
    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                                        }
    130138                                        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);
    133140                                        $parser = new SimplePie_HTTP_Parser($this->headers);
    134141                                        if ($parser->parse())
    135142                                        {
    136143                                                $this->headers = $parser->headers;
    137                                                 $this->body = $parser->body;
     144                                                $this->body = trim($parser->body);
    138145                                                $this->status_code = $parser->status_code;
    139146                                                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)
     
    141148                                                        $this->redirects++;
    142149                                                        $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;
    144154                                                }
    145155                                        }
     
    223233                                                                $this->redirects++;
    224234                                                                $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;
    226239                                                        }
    227240                                                        if (isset($this->headers['content-encoding']))
     
    240253                                                                                else
    241254                                                                                {
    242                                                                                         $this->body = $decoder->data;
     255                                                                                        $this->body = trim($decoder->data);
    243256                                                                                }
    244257                                                                                break;
     
    283296                {
    284297                        $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))))
    286299                        {
    287300                                $this->error = 'file_get_contents could not read the file';
  • trunk/src/wp-includes/SimplePie/HTTP/Parser.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    157156                        return true;
    158157                }
    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;
    168165        }
    169166
     
    498495                }
    499496        }
     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        }
    500518}
  • trunk/src/wp-includes/SimplePie/IRI.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    4847 * @package SimplePie
    4948 * @subpackage HTTP
    50  * @author Geoffrey Sneddon
     49 * @author Sam Sneddon
    5150 * @author Steve Minutillo
    5251 * @author Ryan McCue
    53  * @copyright 2007-2012 Geoffrey Sneddon, Steve Minutillo, Ryan McCue
     52 * @copyright 2007-2012 Sam Sneddon, Steve Minutillo, Ryan McCue
    5453 * @license http://www.opensource.org/licenses/bsd-license.php
    5554 */
     
    213212                        return $this->normalization[$this->scheme][$name];
    214213                }
    215                 else
    216                 {
    217                         return $return;
    218                 }
     214
     215                return $return;
    219216        }
    220217
     
    227224        public function __isset($name)
    228225        {
    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);
    237227        }
    238228
     
    258248        {
    259249                $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);
    260259        }
    261260
     
    349348                                return $target;
    350349                        }
    351                         else
    352                         {
    353                                 return false;
    354                         }
     350
     351                        return false;
    355352                }
    356353        }
     
    389386                        return $match;
    390387                }
    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;
    396391        }
    397392
     
    769764        public function is_valid()
    770765        {
    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;
    789780
    790781                return true;
     
    798789         * @return bool
    799790         */
    800         public function set_iri($iri)
     791        public function set_iri($iri, $clear_cache = false)
    801792        {
    802793                static $cache;
     794                if ($clear_cache)
     795                {
     796                        $cache = null;
     797                        return;
     798                }
    803799                if (!$cache)
    804800                {
     
    822818                        return $return;
    823819                }
    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;
    848842        }
    849843
     
    880874         * @return bool
    881875         */
    882         public function set_authority($authority)
     876        public function set_authority($authority, $clear_cache = false)
    883877        {
    884878                static $cache;
     879                if ($clear_cache)
     880                {
     881                        $cache = null;
     882                        return;
     883                }
    885884                if (!$cache)
    886885                        $cache = array();
     
    902901                        return $return;
    903902                }
     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                }
    904910                else
    905911                {
    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)
    925917                        {
    926918                                $port = null;
    927919                        }
    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;
    940937        }
    941938
     
    10371034                        return true;
    10381035                }
    1039                 else
    1040                 {
    1041                         $this->port = null;
    1042                         return false;
    1043                 }
     1036
     1037                $this->port = null;
     1038                return false;
    10441039        }
    10451040
     
    10501045         * @return bool
    10511046         */
    1052         public function set_path($ipath)
     1047        public function set_path($ipath, $clear_cache = false)
    10531048        {
    10541049                static $cache;
     1050                if ($clear_cache)
     1051                {
     1052                        $cache = null;
     1053                        return;
     1054                }
    10551055                if (!$cache)
    10561056                {
     
    11671167                        $iri .= $this->ipath;
    11681168                }
    1169                 elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '')
     1169        elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '')
    11701170                {
    11711171                        $iri .= $this->normalization[$this->scheme]['ipath'];
     
    12111211                                $iauthority .= $this->ihost;
    12121212                        }
    1213                         if ($this->port !== null)
     1213            if ($this->port !== null && $this->port !== 0)
    12141214                        {
    12151215                                $iauthority .= ':' . $this->port;
     
    12171217                        return $iauthority;
    12181218                }
    1219                 else
    1220                 {
    1221                         return null;
    1222                 }
     1219
     1220                return null;
    12231221        }
    12241222
     
    12331231                if (is_string($iauthority))
    12341232                        return $this->to_uri($iauthority);
    1235                 else
    1236                         return $iauthority;
     1233
     1234                return $iauthority;
    12371235        }
    12381236}
  • trunk/src/wp-includes/SimplePie/Item.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    123122        public function __destruct()
    124123        {
    125                 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
     124                if (!gc_enabled())
    126125                {
    127126                        unset($this->feed);
     
    149148                        return $this->data['child'][$namespace][$tag];
    150149                }
    151                 else
    152                 {
    153                         return null;
    154                 }
     150
     151                return null;
    155152        }
    156153
     
    204201         * Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute
    205202         * 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.
    208204         *
    209205         * @since Beta 2
    210206         * @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')
    214211        {
    215212                if (!$hash)
     
    239236                                return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT);
    240237                        }
    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());
    258250        }
    259251
     
    323315        public function get_description($description_only = false)
    324316        {
    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;
    360361                }
    361362
     
    364365                        return $this->get_content(true);
    365366                }
    366                 else
    367                 {
    368                         return null;
    369                 }
     367
     368                return null;
    370369        }
    371370
     
    386385        public function get_content($content_only = false)
    387386        {
    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;
    399401                }
    400402                elseif (!$content_only)
     
    402404                        return $this->get_description(true);
    403405                }
    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'];
    408432        }
    409433
     
    422446                        return $categories[$key];
    423447                }
    424                 else
    425                 {
    426                         return null;
    427                 }
     448
     449                return null;
    428450        }
    429451
     
    434456         *
    435457         * @since Beta 3
    436          * @return array|null List of {@see SimplePie_Category} objects
     458         * @return SimplePie_Category[]|null List of {@see SimplePie_Category} objects
    437459         */
    438460        public function get_categories()
     
    440462                $categories = array();
    441463
    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)
    443466                {
    444467                        $term = null;
     
    457480                                $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT);
    458481                        }
    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)
    462485                {
    463486                        // This is really the label, but keep this as the term also for BC.
     
    472495                                $scheme = null;
    473496                        }
    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));
    483508                }
    484509
     
    487512                        return array_unique($categories);
    488513                }
    489                 else
    490                 {
    491                         return null;
    492                 }
     514
     515                return null;
    493516        }
    494517
     
    507530                        return $authors[$key];
    508531                }
    509                 else
    510                 {
    511                         return null;
    512                 }
     532
     533                return null;
    513534        }
    514535
     
    527548                        return $contributors[$key];
    528549                }
    529                 else
    530                 {
    531                         return null;
    532                 }
     550
     551                return null;
    533552        }
    534553
     
    539558         *
    540559         * @since 1.1
    541          * @return array|null List of {@see SimplePie_Author} objects
     560         * @return SimplePie_Author[]|null List of {@see SimplePie_Author} objects
    542561         */
    543562        public function get_contributors()
     
    593612                        return array_unique($contributors);
    594613                }
    595                 else
    596                 {
    597                         return null;
    598                 }
     614
     615                return null;
    599616        }
    600617
     
    605622         *
    606623         * @since Beta 2
    607          * @return array|null List of {@see SimplePie_Author} objects
     624         * @return SimplePie_Author[]|null List of {@see SimplePie_Author} objects
    608625         */
    609626        public function get_authors()
     
    683700                        return $authors;
    684701                }
    685                 else
    686                 {
    687                         return null;
    688                 }
     702
     703                return null;
    689704        }
    690705
     
    711726                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    712727                }
    713                 else
    714                 {
    715                         return null;
    716                 }
     728
     729                return null;
    717730        }
    718731
     
    739752                                $this->data['date']['raw'] = $return[0]['data'];
    740753                        }
     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                        }
    741766                        elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
    742767                        {
     
    752777                        }
    753778                        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'))
    766779                        {
    767780                                $this->data['date']['raw'] = $return[0]['data'];
     
    793806                        }
    794807                }
    795                 else
    796                 {
    797                         return null;
    798                 }
     808
     809                return null;
    799810        }
    800811
     
    822833                        {
    823834                                $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']);
    825836                        }
    826837                        else
     
    844855                        }
    845856                }
    846                 else
    847                 {
    848                         return null;
    849                 }
     857
     858                return null;
    850859        }
    851860
     
    873882                        return strftime($date_format, $date);
    874883                }
    875                 else
    876                 {
    877                         return null;
    878                 }
     884
     885                return null;
    879886        }
    880887
     
    937944                        return $enclosure->get_link();
    938945                }
    939                 else
    940                 {
    941                         return null;
    942                 }
     946
     947                return null;
    943948        }
    944949
     
    954959        {
    955960                $links = $this->get_links($rel);
    956                 if ($links[$key] !== null)
     961                if ($links && $links[$key] !== null)
    957962                {
    958963                        return $links[$key];
    959964                }
    960                 else
    961                 {
    962                         return null;
    963                 }
     965
     966                return null;
    964967        }
    965968
     
    10411044                        return $this->data['links'][$rel];
    10421045                }
    1043                 else
    1044                 {
    1045                         return null;
    1046                 }
     1046
     1047                return null;
    10471048        }
    10481049
     
    10641065                        return $enclosures[$key];
    10651066                }
    1066                 else
    1067                 {
    1068                         return null;
    1069                 }
     1067
     1068                return null;
    10701069        }
    10711070
     
    10811080         * @since Beta 2
    10821081         * @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 items
     1082         * @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
    10851084         */
    10861085        public function get_enclosures()
     
    26592658                                                if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player']))
    26602659                                                {
    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                                                        }
    26622663                                                }
    26632664                                                else
     
    27342735                                                        foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail)
    27352736                                                        {
    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                                                                }
    27372740                                                        }
    27382741                                                        if (is_array($thumbnails))
     
    27902793                                                $length = ceil($link['attribs']['']['length']);
    27912794                                        }
     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                                        }
    27922803
    27932804                                        // 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));
    27952806                                }
    27962807                        }
     
    28782889                        return $this->data['enclosures'];
    28792890                }
    2880                 else
    2881                 {
    2882                         return null;
    2883                 }
     2891
     2892                return null;
    28842893        }
    28852894
     
    29062915                        return (float) $match[1];
    29072916                }
    2908                 else
    2909                 {
    2910                         return null;
    2911                 }
     2917
     2918                return null;
    29122919        }
    29132920
     
    29382945                        return (float) $match[2];
    29392946                }
    2940                 else
    2941                 {
    2942                         return null;
    2943                 }
     2947
     2948                return null;
    29442949        }
    29452950
     
    29562961                        return $this->registry->create('Source', array($this, $return[0]));
    29572962                }
    2958                 else
    2959                 {
    2960                         return null;
    2961                 }
     2963
     2964                return null;
    29622965        }
    29632966}
    2964 
  • trunk/src/wp-includes/SimplePie/Locator.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    6463        var $checked_feeds = 0;
    6564        var $max_checked_feeds = 10;
     65        var $force_fsockopen = false;
     66        var $curl_options = array();
    6667        protected $registry;
    6768
    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())
    6970        {
    7071                $this->file = $file;
     
    7273                $this->timeout = $timeout;
    7374                $this->max_checked_feeds = $max_checked_feeds;
     75                $this->force_fsockopen = $force_fsockopen;
     76                $this->curl_options = $curl_options;
    7477
    7578                if (class_exists('DOMDocument'))
     
    122125                        if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local))
    123126                        {
    124                                 return $working;
     127                                return $working[0];
    125128                        }
    126129
    127130                        if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local))
    128131                        {
    129                                 return $working;
     132                                return $working[0];
    130133                        }
    131134
    132135                        if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere))
    133136                        {
    134                                 return $working;
     137                                return $working[0];
    135138                        }
    136139
    137140                        if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere))
    138141                        {
    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)
    146149        {
    147150                if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE)
     
    149152                        $sniffer = $this->registry->create('Content_Type_Sniffer', array($file));
    150153                        $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);
    159163                }
    160164                elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
     
    205209                        return array_values($feeds);
    206210                }
    207                 else
    208                 {
    209                         return null;
    210                 }
     211
     212                return null;
    211213        }
    212214
     
    227229                        if ($link->hasAttribute('href') && $link->hasAttribute('rel'))
    228230                        {
    229                                 $rel = array_unique($this->registry->call('Misc', 'space_seperated_tokens', array(strtolower($link->getAttribute('rel')))));
     231                                $rel = array_unique($this->registry->call('Misc', 'space_separated_tokens', array(strtolower($link->getAttribute('rel')))));
    230232                                $line = method_exists($link, 'getLineNo') ? $link->getLineNo() : 1;
    231233
     
    243245                                }
    244246
    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]))
    246248                                {
    247249                                        $this->checked_feeds++;
     
    249251                                                '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',
    250252                                        );
    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))
    253255                                        {
    254256                                                $feeds[$href] = $feed;
     
    276278                                $href = trim($link->getAttribute('href'));
    277279                                $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']))
    279281                                {
    280282                                        if (method_exists($link, 'getLineNo') && $this->base_location < $link->getLineNo())
     
    313315        }
    314316
     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
    315368        public function extension(&$array)
    316369        {
     
    328381                                        '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',
    329382                                );
    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));
    331384                                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))
    332385                                {
    333                                         return $feed;
     386                                        return array($feed);
    334387                                }
    335388                                else
     
    350403                                break;
    351404                        }
    352                         if (preg_match('/(rss|rdf|atom|xml)/i', $value))
     405                        if (preg_match('/(feed|rss|rdf|atom|xml)/i', $value))
    353406                        {
    354407                                $this->checked_feeds++;
     
    356409                                        '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',
    357410                                );
    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));
    359412                                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))
    360413                                {
    361                                         return $feed;
     414                                        return array($feed);
    362415                                }
    363416                                else
     
    370423        }
    371424}
    372 
  • trunk/src/wp-includes/SimplePie/Misc.php

    r24589 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    139138                {
    140139                        $key = strtolower($key);
    141                         $full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
     140                        $full .= " $key=\"" . htmlspecialchars($value['data'], ENT_COMPAT, 'UTF-8') . '"';
    142141                }
    143142                if ($element['self_closing'])
     
    219218                        return substr_replace($url, 'itpc', 0, 4);
    220219                }
    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;
    225239        }
    226240
     
    261275                        return chr($integer);
    262276                }
    263                 else
    264                 {
    265                         return strtoupper($match[0]);
    266                 }
     277
     278                return strtoupper($match[0]);
    267279        }
    268280
     
    318330                        return $return;
    319331                }
     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                }
    320337                // 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)))
    322339                {
    323340                        return $return;
    324341                }
     342
    325343                // If we can't do anything, just fail
    326                 else
    327                 {
    328                         return false;
    329                 }
     344                return false;
    330345        }
    331346
     
    371386        {
    372387                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);
    373399        }
    374400
     
    18271853                        return trim($mime);
    18281854                }
    1829                 else
    1830                 {
    1831                         return trim(substr($mime, 0, $pos));
    1832                 }
     1855
     1856                return trim(substr($mime, 0, $pos));
    18331857        }
    18341858
     
    18631887                        }
    18641888                }
    1865                 else
    1866                 {
    1867                         return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
    1868                 }
     1889
     1890                return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
    18691891        }
    18701892
     
    19161938                        }
    19171939                }
    1918                 else
    1919                 {
    1920                         return SIMPLEPIE_CONSTRUCT_TEXT;
    1921                 }
     1940
     1941                return SIMPLEPIE_CONSTRUCT_TEXT;
    19221942        }
    19231943
     
    19271947        }
    19281948
    1929         public static function space_seperated_tokens($string)
     1949        public static function space_separated_tokens($string)
    19301950        {
    19311951                $space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
     
    19761996                        return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
    19771997                }
    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";
    19832001        }
    19842002
     
    21842202                        return filemtime(dirname(__FILE__) . '/Core.php');
    21852203                }
    2186                 else
    2187                 {
    2188                         return filemtime(__FILE__);
    2189                 }
     2204
     2205                return filemtime(__FILE__);
    21902206        }
    21912207
     
    22452261        }
    22462262}
    2247 
  • trunk/src/wp-includes/SimplePie/Net/IPv6.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    5554 * @author elfrink at introweb dot nl
    5655 * @author Josh Peck <jmp at joshpeck dot org>
    57  * @author Geoffrey Sneddon <geoffers@gmail.com>
     56 * @author Sam Sneddon <geoffers@gmail.com>
    5857 */
    5958class SimplePie_Net_IPv6
     
    175174                        return implode(':', $ip_parts);
    176175                }
    177                 else
    178                 {
    179                         return $ip_parts[0];
    180                 }
     176
     177                return $ip_parts[0];
    181178        }
    182179
     
    202199                        return array($ipv6_part, $ipv4_part);
    203200                }
    204                 else
    205                 {
    206                         return array($ip, '');
    207                 }
     201
     202                return array($ip, '');
    208203        }
    209204
     
    255250                        return true;
    256251                }
    257                 else
    258                 {
    259                         return false;
    260                 }
     252
     253                return false;
    261254        }
    262255
  • trunk/src/wp-includes/SimplePie/Parse/Date.php

    r46260 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    10099                // German
    101100                'montag' => 1,
     101                'mo' => 1,
    102102                'dienstag' => 2,
     103                'di' => 2,
    103104                'mittwoch' => 3,
     105                'mi' => 3,
    104106                'donnerstag' => 4,
     107                'do' => 4,
    105108                'freitag' => 5,
     109                'fr' => 5,
    106110                'samstag' => 6,
     111                'sa' => 6,
    107112                'sonnabend' => 6,
     113                // AFAIK no short form for sonnabend
     114                'so' => 7,
    108115                'sonntag' => 7,
    109116                // Italian
     
    147154                'Σαβ' => 6,
    148155                'Κυρ' => 7,
     156                // Russian
     157                'Пн.' => 1,
     158                'Вт.' => 2,
     159                'Ср.' => 3,
     160                'Чт.' => 4,
     161                'Пт.' => 5,
     162                'Сб.' => 6,
     163                'Вс.' => 7,
    149164        );
    150165
     
    174189                'august' => 8,
    175190                'sep' => 9,
    176                 'september' => 8,
     191                'september' => 9,
    177192                'oct' => 10,
    178193                'october' => 10,
     
    209224                // German
    210225                'januar' => 1,
     226                'jan' => 1,
    211227                'februar' => 2,
     228                'feb' => 2,
    212229                'märz' => 3,
     230                'mär' => 3,
    213231                'april' => 4,
    214                 'mai' => 5,
     232                'apr' => 4,
     233                'mai' => 5, // no short form for may
    215234                'juni' => 6,
     235                'jun' => 6,
    216236                'juli' => 7,
     237                'jul' => 7,
    217238                'august' => 8,
     239                'aug' => 8,
    218240                'september' => 9,
     241                'sep' => 9,
    219242                'oktober' => 10,
     243                'okt' => 10,
    220244                'november' => 11,
     245                'nov' => 11,
    221246                'dezember' => 12,
     247                'dez' => 12,
    222248                // Italian
    223249                'gennaio' => 1,
     
    291317                'Οκτ' => 10,
    292318                'Νοέ' => 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
    294346        );
    295347
     
    615667         * @final
    616668         * @access public
    617          * @param callable $callback
     669         * @param callback $callback
    618670         */
    619671        public function add_callback($callback)
     
    632684         * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as
    633685         * well as allowing any of upper or lower case "T", horizontal tabs, or
    634          * spaces to be used as the time seperator (including more than one))
     686         * spaces to be used as the time separator (including more than one))
    635687         *
    636688         * @access protected
     
    692744
    693745                        // 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])));
    695747
    696748                        return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
    697749                }
    698                 else
    699                 {
    700                         return false;
    701                 }
     750
     751                return false;
    702752        }
    703753
     
    722772                        $output .= substr($string, $position, $pos - $position);
    723773                        $position = $pos + 1;
    724                         if ($string[$pos - 1] !== '\\')
     774                        if ($pos === 0 || $string[$pos - 1] !== '\\')
    725775                        {
    726776                                $depth++;
     
    850900                        return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone;
    851901                }
    852                 else
    853                 {
    854                         return false;
    855                 }
     902
     903                return false;
    856904        }
    857905
     
    915963                        return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone;
    916964                }
    917                 else
    918                 {
    919                         return false;
    920                 }
     965
     966                return false;
    921967        }
    922968
     
    9571003                        return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]);
    9581004                }
    959                 else
    960                 {
    961                         return false;
    962                 }
     1005
     1006                return false;
    9631007        }
    9641008
     
    9761020                        return false;
    9771021                }
    978                 else
    979                 {
    980                         return $strtotime;
    981                 }
     1022
     1023                return $strtotime;
    9821024        }
    9831025}
    984 
  • trunk/src/wp-includes/SimplePie/Parser.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    7675        }
    7776
    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
    8093                // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character
    8194                if (strtoupper($encoding) === 'US-ASCII')
     
    121134                        {
    122135                                $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;
    124137                        }
    125138                        else
     
    164177                        return $return;
    165178                }
    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                                        {
    177212                                                if ($xml->namespaceURI !== '')
    178213                                                {
    179                                                         $tagName = $xml->namespaceURI . $this->separator . $xml->localName;
     214                                                        $attrName = $xml->namespaceURI . $this->separator . $xml->localName;
    180215                                                }
    181216                                                else
    182217                                                {
    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                                        {
    185225                                                $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;
    236245        }
    237246
     
    405414                return $cache[$string];
    406415        }
     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 "&#x00A0;"> <!ENTITY iexcl "&#x00A1;"> <!ENTITY cent "&#x00A2;"> <!ENTITY pound "&#x00A3;"> <!ENTITY curren "&#x00A4;"> <!ENTITY yen "&#x00A5;"> <!ENTITY brvbar "&#x00A6;"> <!ENTITY sect "&#x00A7;"> <!ENTITY uml "&#x00A8;"> <!ENTITY copy "&#x00A9;"> <!ENTITY ordf "&#x00AA;"> <!ENTITY laquo "&#x00AB;"> <!ENTITY not "&#x00AC;"> <!ENTITY shy "&#x00AD;"> <!ENTITY reg "&#x00AE;"> <!ENTITY macr "&#x00AF;"> <!ENTITY deg "&#x00B0;"> <!ENTITY plusmn "&#x00B1;"> <!ENTITY sup2 "&#x00B2;"> <!ENTITY sup3 "&#x00B3;"> <!ENTITY acute "&#x00B4;"> <!ENTITY micro "&#x00B5;"> <!ENTITY para "&#x00B6;"> <!ENTITY middot "&#x00B7;"> <!ENTITY cedil "&#x00B8;"> <!ENTITY sup1 "&#x00B9;"> <!ENTITY ordm "&#x00BA;"> <!ENTITY raquo "&#x00BB;"> <!ENTITY frac14 "&#x00BC;"> <!ENTITY frac12 "&#x00BD;"> <!ENTITY frac34 "&#x00BE;"> <!ENTITY iquest "&#x00BF;"> <!ENTITY Agrave "&#x00C0;"> <!ENTITY Aacute "&#x00C1;"> <!ENTITY Acirc "&#x00C2;"> <!ENTITY Atilde "&#x00C3;"> <!ENTITY Auml "&#x00C4;"> <!ENTITY Aring "&#x00C5;"> <!ENTITY AElig "&#x00C6;"> <!ENTITY Ccedil "&#x00C7;"> <!ENTITY Egrave "&#x00C8;"> <!ENTITY Eacute "&#x00C9;"> <!ENTITY Ecirc "&#x00CA;"> <!ENTITY Euml "&#x00CB;"> <!ENTITY Igrave "&#x00CC;"> <!ENTITY Iacute "&#x00CD;"> <!ENTITY Icirc "&#x00CE;"> <!ENTITY Iuml "&#x00CF;"> <!ENTITY ETH "&#x00D0;"> <!ENTITY Ntilde "&#x00D1;"> <!ENTITY Ograve "&#x00D2;"> <!ENTITY Oacute "&#x00D3;"> <!ENTITY Ocirc "&#x00D4;"> <!ENTITY Otilde "&#x00D5;"> <!ENTITY Ouml "&#x00D6;"> <!ENTITY times "&#x00D7;"> <!ENTITY Oslash "&#x00D8;"> <!ENTITY Ugrave "&#x00D9;"> <!ENTITY Uacute "&#x00DA;"> <!ENTITY Ucirc "&#x00DB;"> <!ENTITY Uuml "&#x00DC;"> <!ENTITY Yacute "&#x00DD;"> <!ENTITY THORN "&#x00DE;"> <!ENTITY szlig "&#x00DF;"> <!ENTITY agrave "&#x00E0;"> <!ENTITY aacute "&#x00E1;"> <!ENTITY acirc "&#x00E2;"> <!ENTITY atilde "&#x00E3;"> <!ENTITY auml "&#x00E4;"> <!ENTITY aring "&#x00E5;"> <!ENTITY aelig "&#x00E6;"> <!ENTITY ccedil "&#x00E7;"> <!ENTITY egrave "&#x00E8;"> <!ENTITY eacute "&#x00E9;"> <!ENTITY ecirc "&#x00EA;"> <!ENTITY euml "&#x00EB;"> <!ENTITY igrave "&#x00EC;"> <!ENTITY iacute "&#x00ED;"> <!ENTITY icirc "&#x00EE;"> <!ENTITY iuml "&#x00EF;"> <!ENTITY eth "&#x00F0;"> <!ENTITY ntilde "&#x00F1;"> <!ENTITY ograve "&#x00F2;"> <!ENTITY oacute "&#x00F3;"> <!ENTITY ocirc "&#x00F4;"> <!ENTITY otilde "&#x00F5;"> <!ENTITY ouml "&#x00F6;"> <!ENTITY divide "&#x00F7;"> <!ENTITY oslash "&#x00F8;"> <!ENTITY ugrave "&#x00F9;"> <!ENTITY uacute "&#x00FA;"> <!ENTITY ucirc "&#x00FB;"> <!ENTITY uuml "&#x00FC;"> <!ENTITY yacute "&#x00FD;"> <!ENTITY thorn "&#x00FE;"> <!ENTITY yuml "&#x00FF;"> <!ENTITY OElig "&#x0152;"> <!ENTITY oelig "&#x0153;"> <!ENTITY Scaron "&#x0160;"> <!ENTITY scaron "&#x0161;"> <!ENTITY Yuml "&#x0178;"> <!ENTITY fnof "&#x0192;"> <!ENTITY circ "&#x02C6;"> <!ENTITY tilde "&#x02DC;"> <!ENTITY Alpha "&#x0391;"> <!ENTITY Beta "&#x0392;"> <!ENTITY Gamma "&#x0393;"> <!ENTITY Epsilon "&#x0395;"> <!ENTITY Zeta "&#x0396;"> <!ENTITY Eta "&#x0397;"> <!ENTITY Theta "&#x0398;"> <!ENTITY Iota "&#x0399;"> <!ENTITY Kappa "&#x039A;"> <!ENTITY Lambda "&#x039B;"> <!ENTITY Mu "&#x039C;"> <!ENTITY Nu "&#x039D;"> <!ENTITY Xi "&#x039E;"> <!ENTITY Omicron "&#x039F;"> <!ENTITY Pi "&#x03A0;"> <!ENTITY Rho "&#x03A1;"> <!ENTITY Sigma "&#x03A3;"> <!ENTITY Tau "&#x03A4;"> <!ENTITY Upsilon "&#x03A5;"> <!ENTITY Phi "&#x03A6;"> <!ENTITY Chi "&#x03A7;"> <!ENTITY Psi "&#x03A8;"> <!ENTITY Omega "&#x03A9;"> <!ENTITY alpha "&#x03B1;"> <!ENTITY beta "&#x03B2;"> <!ENTITY gamma "&#x03B3;"> <!ENTITY delta "&#x03B4;"> <!ENTITY epsilon "&#x03B5;"> <!ENTITY zeta "&#x03B6;"> <!ENTITY eta "&#x03B7;"> <!ENTITY theta "&#x03B8;"> <!ENTITY iota "&#x03B9;"> <!ENTITY kappa "&#x03BA;"> <!ENTITY lambda "&#x03BB;"> <!ENTITY mu "&#x03BC;"> <!ENTITY nu "&#x03BD;"> <!ENTITY xi "&#x03BE;"> <!ENTITY omicron "&#x03BF;"> <!ENTITY pi "&#x03C0;"> <!ENTITY rho "&#x03C1;"> <!ENTITY sigmaf "&#x03C2;"> <!ENTITY sigma "&#x03C3;"> <!ENTITY tau "&#x03C4;"> <!ENTITY upsilon "&#x03C5;"> <!ENTITY phi "&#x03C6;"> <!ENTITY chi "&#x03C7;"> <!ENTITY psi "&#x03C8;"> <!ENTITY omega "&#x03C9;"> <!ENTITY thetasym "&#x03D1;"> <!ENTITY upsih "&#x03D2;"> <!ENTITY piv "&#x03D6;"> <!ENTITY ensp "&#x2002;"> <!ENTITY emsp "&#x2003;"> <!ENTITY thinsp "&#x2009;"> <!ENTITY zwnj "&#x200C;"> <!ENTITY zwj "&#x200D;"> <!ENTITY lrm "&#x200E;"> <!ENTITY rlm "&#x200F;"> <!ENTITY ndash "&#x2013;"> <!ENTITY mdash "&#x2014;"> <!ENTITY lsquo "&#x2018;"> <!ENTITY rsquo "&#x2019;"> <!ENTITY sbquo "&#x201A;"> <!ENTITY ldquo "&#x201C;"> <!ENTITY rdquo "&#x201D;"> <!ENTITY bdquo "&#x201E;"> <!ENTITY dagger "&#x2020;"> <!ENTITY Dagger "&#x2021;"> <!ENTITY bull "&#x2022;"> <!ENTITY hellip "&#x2026;"> <!ENTITY permil "&#x2030;"> <!ENTITY prime "&#x2032;"> <!ENTITY Prime "&#x2033;"> <!ENTITY lsaquo "&#x2039;"> <!ENTITY rsaquo "&#x203A;"> <!ENTITY oline "&#x203E;"> <!ENTITY frasl "&#x2044;"> <!ENTITY euro "&#x20AC;"> <!ENTITY image "&#x2111;"> <!ENTITY weierp "&#x2118;"> <!ENTITY real "&#x211C;"> <!ENTITY trade "&#x2122;"> <!ENTITY alefsym "&#x2135;"> <!ENTITY larr "&#x2190;"> <!ENTITY uarr "&#x2191;"> <!ENTITY rarr "&#x2192;"> <!ENTITY darr "&#x2193;"> <!ENTITY harr "&#x2194;"> <!ENTITY crarr "&#x21B5;"> <!ENTITY lArr "&#x21D0;"> <!ENTITY uArr "&#x21D1;"> <!ENTITY rArr "&#x21D2;"> <!ENTITY dArr "&#x21D3;"> <!ENTITY hArr "&#x21D4;"> <!ENTITY forall "&#x2200;"> <!ENTITY part "&#x2202;"> <!ENTITY exist "&#x2203;"> <!ENTITY empty "&#x2205;"> <!ENTITY nabla "&#x2207;"> <!ENTITY isin "&#x2208;"> <!ENTITY notin "&#x2209;"> <!ENTITY ni "&#x220B;"> <!ENTITY prod "&#x220F;"> <!ENTITY sum "&#x2211;"> <!ENTITY minus "&#x2212;"> <!ENTITY lowast "&#x2217;"> <!ENTITY radic "&#x221A;"> <!ENTITY prop "&#x221D;"> <!ENTITY infin "&#x221E;"> <!ENTITY ang "&#x2220;"> <!ENTITY and "&#x2227;"> <!ENTITY or "&#x2228;"> <!ENTITY cap "&#x2229;"> <!ENTITY cup "&#x222A;"> <!ENTITY int "&#x222B;"> <!ENTITY there4 "&#x2234;"> <!ENTITY sim "&#x223C;"> <!ENTITY cong "&#x2245;"> <!ENTITY asymp "&#x2248;"> <!ENTITY ne "&#x2260;"> <!ENTITY equiv "&#x2261;"> <!ENTITY le "&#x2264;"> <!ENTITY ge "&#x2265;"> <!ENTITY sub "&#x2282;"> <!ENTITY sup "&#x2283;"> <!ENTITY nsub "&#x2284;"> <!ENTITY sube "&#x2286;"> <!ENTITY supe "&#x2287;"> <!ENTITY oplus "&#x2295;"> <!ENTITY otimes "&#x2297;"> <!ENTITY perp "&#x22A5;"> <!ENTITY sdot "&#x22C5;"> <!ENTITY lceil "&#x2308;"> <!ENTITY rceil "&#x2309;"> <!ENTITY lfloor "&#x230A;"> <!ENTITY rfloor "&#x230B;"> <!ENTITY lang "&#x2329;"> <!ENTITY rang "&#x232A;"> <!ENTITY loz "&#x25CA;"> <!ENTITY spades "&#x2660;"> <!ENTITY clubs "&#x2663;"> <!ENTITY hearts "&#x2665;"> <!ENTITY diams "&#x2666;"> ]>';
     660        }
    407661}
  • trunk/src/wp-includes/SimplePie/Rating.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    105104                        return $this->scheme;
    106105                }
    107                 else
    108                 {
    109                         return null;
    110                 }
     106
     107                return null;
    111108        }
    112109
     
    122119                        return $this->value;
    123120                }
    124                 else
    125                 {
    126                         return null;
    127                 }
     121
     122                return null;
    128123        }
    129124}
  • trunk/src/wp-includes/SimplePie/Registry.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    114113        public function register($type, $class, $legacy = false)
    115114        {
    116                 if (!is_subclass_of($class, $this->default[$type]))
     115                if (!@is_subclass_of($class, $this->default[$type]))
    117116                {
    118117                        return false;
  • trunk/src/wp-includes/SimplePie/Restriction.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    114113                        return $this->relationship;
    115114                }
    116                 else
    117                 {
    118                         return null;
    119                 }
     115
     116                return null;
    120117        }
    121118
     
    131128                        return $this->type;
    132129                }
    133                 else
    134                 {
    135                         return null;
    136                 }
     130
     131                return null;
    137132        }
    138133
     
    148143                        return $this->value;
    149144                }
    150                 else
    151                 {
    152                         return null;
    153                 }
     145
     146                return null;
    154147        }
    155148}
  • trunk/src/wp-includes/SimplePie/Sanitize.php

    r25342 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    6261        var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
    6362        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'));
    6565        var $strip_comments = false;
    6666        var $output_encoding = 'UTF-8';
     
    161161        }
    162162
    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'))
    164164        {
    165165                if ($attribs)
     
    177177                {
    178178                        $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;
    179198                }
    180199        }
     
    250269                                if (!class_exists('DOMDocument'))
    251270                                {
    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');
    254272                                }
    255273                                $document = new DOMDocument();
    256274                                $document->encoding = 'UTF-8';
     275
    257276                                $data = $this->preprocess($data, $type);
    258277
     
    261280                                restore_error_handler();
    262281
     282                                $xpath = new DOMXPath($document);
     283
    263284                                // Strip comments
    264285                                if ($this->strip_comments)
    265286                                {
    266                                         $xpath = new DOMXPath($document);
    267287                                        $comments = $xpath->query('//comment()');
    268288
     
    280300                                        foreach ($this->strip_htmltags as $tag)
    281301                                        {
    282                                                 $this->strip_tag($tag, $document, $type);
     302                                                $this->strip_tag($tag, $document, $xpath, $type);
    283303                                        }
    284304                                }
     
    288308                                        foreach ($this->strip_attributes as $attrib)
    289309                                        {
    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);
    291319                                        }
    292320                                }
     
    327355                                                                        else
    328356                                                                        {
    329                                                                                 trigger_error("$this->cache_location is not writeable. 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);
    330358                                                                        }
    331359                                                                }
     
    335363                                }
    336364
    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;
    348367                                // Finally, convert to a HTML string
    349                                 $data = trim($document->saveHTML());
     368                                $data = trim($document->saveHTML($div));
    350369
    351370                                if ($this->remove_div)
     
    385404        {
    386405                $ret = '';
     406                $html = preg_replace('%</?(?:html|body)[^>]*?'.'>%is', '', $html);
    387407                if ($type & ~SIMPLEPIE_CONSTRUCT_XHTML)
    388408                {
     
    457477        }
    458478
    459         protected function strip_tag($tag, $document, $type)
    460         {
    461                 $xpath = new DOMXPath($document);
     479        protected function strip_tag($tag, $document, $xpath, $type)
     480        {
    462481                $elements = $xpath->query('body//' . $tag);
    463482                if ($this->encode_instead_of_strip)
     
    542561        }
    543562
    544         protected function strip_attr($attrib, $document)
    545         {
    546                 $xpath = new DOMXPath($document);
     563        protected function strip_attr($attrib, $xpath)
     564        {
    547565                $elements = $xpath->query('//*[@' . $attrib . ']');
    548566
     
    552570                }
    553571        }
     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        }
    554584}
  • trunk/src/wp-includes/SimplePie/Source.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    8180                        return $this->data['child'][$namespace][$tag];
    8281                }
    83                 else
    84                 {
    85                         return null;
    86                 }
     82
     83                return null;
    8784        }
    8885
     
    132129                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    133130                }
    134                 else
    135                 {
    136                         return null;
    137                 }
     131
     132                return null;
    138133        }
    139134
     
    145140                        return $categories[$key];
    146141                }
    147                 else
    148                 {
    149                         return null;
    150                 }
     142
     143                return null;
    151144        }
    152145
     
    202195                        return array_unique($categories);
    203196                }
    204                 else
    205                 {
    206                         return null;
    207                 }
     197
     198                return null;
    208199        }
    209200
     
    215206                        return $authors[$key];
    216207                }
    217                 else
    218                 {
    219                         return null;
    220                 }
     208
     209                return null;
    221210        }
    222211
     
    285274                        return array_unique($authors);
    286275                }
    287                 else
    288                 {
    289                         return null;
    290                 }
     276
     277                return null;
    291278        }
    292279
     
    298285                        return $contributors[$key];
    299286                }
    300                 else
    301                 {
    302                         return null;
    303                 }
     287
     288                return null;
    304289        }
    305290
     
    356341                        return array_unique($contributors);
    357342                }
    358                 else
    359                 {
    360                         return null;
    361                 }
     343
     344                return null;
    362345        }
    363346
     
    369352                        return $links[$key];
    370353                }
    371                 else
    372                 {
    373                         return null;
    374                 }
     354
     355                return null;
    375356        }
    376357
     
    451432                        return $this->data['links'][$rel];
    452433                }
    453                 else
    454                 {
    455                         return null;
    456                 }
     434
     435                return null;
    457436        }
    458437
     
    495474                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
    496475                }
    497                 else
    498                 {
    499                         return null;
    500                 }
     476
     477                return null;
    501478        }
    502479
     
    523500                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    524501                }
    525                 else
    526                 {
    527                         return null;
    528                 }
     502
     503                return null;
    529504        }
    530505
     
    547522                        return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT);
    548523                }
    549                 else
    550                 {
    551                         return null;
    552                 }
     524
     525                return null;
    553526        }
    554527
     
    563536                        return (float) $match[1];
    564537                }
    565                 else
    566                 {
    567                         return null;
    568                 }
     538
     539                return null;
    569540        }
    570541
     
    583554                        return (float) $match[2];
    584555                }
    585                 else
    586                 {
    587                         return null;
    588                 }
     556
     557                return null;
    589558        }
    590559
     
    603572                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
    604573                }
    605                 else
    606                 {
    607                         return null;
    608                 }
     574
     575                return null;
    609576        }
    610577}
    611 
  • trunk/src/wp-includes/SimplePie/XML/Declaration/Parser.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    138137                        return true;
    139138                }
    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;
    147144        }
    148145
  • trunk/src/wp-includes/SimplePie/gzdecode.php

    r22798 r47733  
    66 * Takes the hard work out of managing a complete RSS/Atom solution.
    77 *
    8  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     8 * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    99 * All rights reserved.
    1010 *
     
    3434 *
    3535 * @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
    3837 * @author Ryan Parman
    39  * @author Geoffrey Sneddon
     38 * @author Sam Sneddon
    4039 * @author Ryan McCue
    4140 * @link http://simplepie.org/ SimplePie
     
    340339                                return false;
    341340                        }
    342                         else
    343                         {
    344                                 $this->position = $this->compressed_size - 8;
    345                         }
     341
     342                        $this->position = $this->compressed_size - 8;
    346343
    347344                        // Check CRC of data
     
    364361                        return true;
    365362                }
    366                 else
    367                 {
    368                         return false;
    369                 }
     363
     364                return false;
    370365        }
    371366}
  • trunk/src/wp-includes/class-simplepie.php

    r47198 r47733  
    4141 * Takes the hard work out of managing a complete RSS/Atom solution.
    4242 *
    43  * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
     43 * Copyright (c) 2004-2017, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    4444 * All rights reserved.
    4545 *
     
    6969 *
    7070 * @package SimplePie
    71  * @version 1.3.1
    72  * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
     71 * @version 1.5.5
     72 * @copyright 2004-2017 Ryan Parman, Sam Sneddon, Ryan McCue
    7373 * @author Ryan Parman
    74  * @author Geoffrey Sneddon
     74 * @author Sam Sneddon
    7575 * @author Ryan McCue
    7676 * @link http://simplepie.org/ SimplePie
     
    8686 * SimplePie Version
    8787 */
    88 define('SIMPLEPIE_VERSION', '1.3.1');
     88define('SIMPLEPIE_VERSION', '1.5.5');
    8989
    9090/**
     
    482482
    483483        /**
     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        /**
    484491         * @var object Instance of SimplePie_File to use as a feed
    485492         * @see SimplePie::set_file()
     
    501508         */
    502509        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();
    503517
    504518        /**
     
    526540
    527541        /**
     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        /**
    528550         * @var int Cache duration (in seconds)
    529551         * @see SimplePie::set_cache_duration()
     
    631653
    632654        /**
     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        /**
    633661         * @var array Stores the default attributes to be stripped by strip_attributes().
    634662         * @see SimplePie::strip_attributes()
     
    638666
    639667        /**
     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        /**
    640675         * @var array Stores the default tags to be stripped by strip_htmltags().
    641676         * @see SimplePie::strip_htmltags()
     
    643678         */
    644679        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;
    645686
    646687        /**
     
    660701        public function __construct()
    661702        {
    662                 if (version_compare(PHP_VERSION, '5.2', '<'))
    663                 {
    664                         trigger_error('PHP 4.x, 5.0 and 5.1 are no longer supported. Please upgrade to PHP 5.2 or newer.');
     703                if (version_compare(PHP_VERSION, '5.6', '<'))
     704                {
     705                        trigger_error('Please upgrade to PHP 5.6 or newer.');
    665706                        die();
    666707                }
     
    673714                {
    674715                        $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);
    676717
    677718                        $args = func_get_args();
     
    701742        public function __destruct()
    702743        {
    703                 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
     744                if (!gc_enabled())
    704745                {
    705746                        if (!empty($this->data['items']))
     
    764805                {
    765806                        $this->feed_url = $this->registry->call('Misc', 'fix_protocol', array($url, 1));
     807                        $this->permanent_url = $this->feed_url;
    766808                }
    767809        }
     
    778820                {
    779821                        $this->feed_url = $file->url;
     822                        $this->permanent_url = $this->feed_url;
    780823                        $this->file =& $file;
    781824                        return true;
     
    803846
    804847        /**
    805          * Set the the default timeout for fetching remote feeds
     848         * Set the default timeout for fetching remote feeds
    806849         *
    807850         * This allows you to change the maximum time the feed's server to respond
     
    817860
    818861        /**
     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        /**
    819875         * Force SimplePie to use fsockopen() instead of cURL
    820876         *
     
    839895        {
    840896                $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;
    841912        }
    842913
     
    11091180                        $this->strip_htmltags(false);
    11101181                        $this->strip_attributes(false);
     1182                        $this->add_attributes(false);
    11111183                        $this->set_image_handler(false);
    11121184                }
     
    11551227        }
    11561228
     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
    11571238        /**
    11581239         * Set the output encoding
     
    11601241         * Allows you to override SimplePie's output to match that of your webpage.
    11611242         * This is useful for times when your webpages are not being served as
    1162          * UTF-8.  This setting will be obeyed by {@see handle_content_type()}, and
     1243         * UTF-8. This setting will be obeyed by {@see handle_content_type()}, and
    11631244         * is similar to {@see set_input_encoding()}.
    11641245         *
    11651246         * It should be noted, however, that not all character encodings can support
    1166          * all characters.  If your page is being served as ISO-8859-1 and you try
     1247         * all characters. If your page is being served as ISO-8859-1 and you try
    11671248         * to display a Japanese feed, you'll likely see garbled characters.
    11681249         * Because of this, it is highly recommended to ensure that your webpages
     
    12061287         * Set the handler to enable the display of cached images.
    12071288         *
    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.
    12101291         */
    12111292        public function set_image_handler($page = false, $qs = 'i')
     
    12321313
    12331314        /**
     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        /**
    12341325         * Initialize the feed object
    12351326         *
    1236          * This is what makes everything happen.  Period. This is where all of the
     1327         * This is what makes everything happen. Period. This is where all of the
    12371328         * configuration options get processed, feeds are fetched, cached, and
    12381329         * parsed, and all of that other good stuff.
     
    12451336                if (!extension_loaded('xml') || !extension_loaded('pcre'))
    12461337                {
     1338                        $this->error = 'XML or PCRE extensions not loaded!';
    12471339                        return false;
    12481340                }
     
    12641356                }
    12651357
     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                }
    12661363                if (method_exists($this->sanitize, 'set_registry'))
    12671364                {
     
    12721369                // Pass the classes in for legacy support; new classes should use the registry instead
    12731370                $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);
    12751372
    12761373                if (!empty($this->multifeed_url))
     
    13011398                $this->error = null;
    13021399                $this->data = array();
     1400                $this->check_modified = false;
    13031401                $this->multifeed_objects = array();
    13041402                $cache = false;
     
    13111409                        if ($this->cache && $parsed_feed_url['scheme'] !== '')
    13121410                        {
    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'));
    13141413                        }
    13151414
     
    13261425                }
    13271426
     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
    13281434                // Set up array of possible encodings
    13291435                $encodings = array();
     
    13321438                if ($this->input_encoding !== false)
    13331439                {
    1334                         $encodings[] = $this->input_encoding;
     1440                        $encodings[] = strtoupper($this->input_encoding);
    13351441                }
    13361442
     
    13541460                                if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset))
    13551461                                {
    1356                                         $encodings[] = $charset[1];
     1462                                        $encodings[] = strtoupper($charset[1]);
    13571463                                }
    13581464                                $encodings[] = 'US-ASCII';
     
    13611467                        elseif (substr($sniffed, 0, 5) === 'text/')
    13621468                        {
    1363                                 $encodings[] = 'US-ASCII';
     1469                                $encodings[] = 'UTF-8';
    13641470                        }
    13651471                }
     
    13831489
    13841490                                // If it's parsed fine
    1385                                 if ($parser->parse($utf8_data, 'UTF-8'))
     1491                                if ($parser->parse($utf8_data, 'UTF-8', $this->permanent_url))
    13861492                                {
    13871493                                        $this->data = $parser->get_data();
    13881494                                        if (!($this->get_type() & ~SIMPLEPIE_TYPE_NONE))
    13891495                                        {
    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.";
    13911497                                                $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__));
    13921498                                                return false;
     
    14021508                                        if ($cache && !$cache->save($this))
    14031509                                        {
    1404                                                 trigger_error("$this->cache_location is not writeable. 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);
    14051511                                        }
    14061512                                        return true;
     
    14121518                {
    14131519                        // 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());
    14151522                }
    14161523                else
    14171524                {
    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                        }
    14191541                }
    14201542
     
    14721594                                elseif ($cache->mtime() + $this->cache_duration < time())
    14731595                                {
    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;
    14751600                                        if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
    14761601                                        {
     
    14871612                                                }
    14881613
    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));
    14901615
    14911616                                                if ($file->success)
     
    14931618                                                        if ($file->status_code === 304)
    14941619                                                        {
     1620                                                                // Set raw_data to false here too, to signify that the cache
     1621                                                                // is still valid.
     1622                                                                $this->raw_data = false;
    14951623                                                                $cache->touch();
    14961624                                                                return true;
     
    14991627                                                else
    15001628                                                {
     1629                                                        $this->check_modified = false;
     1630                                                        if($this->force_cache_fallback)
     1631                                                        {
     1632                                                                $cache->touch();
     1633                                                                return true;
     1634                                                        }
     1635
    15011636                                                        unset($file);
    15021637                                                }
     
    15291664                                        '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',
    15301665                                );
    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));
    15321667                        }
    15331668                }
     
    15421677                {
    15431678                        // 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));
    15451680
    15461681                        if (!$locate->is_feed($file))
    15471682                        {
    1548                                 // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
    1549                                 unset($file);
     1683                                $copyStatusCode = $file->status_code;
     1684                                $copyContentType = $file->headers['content-type'];
    15501685                                try
    15511686                                {
    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)
    15531704                                        {
    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                                                // Push the current file onto all_discovered feeds so the user can
     1711                                                // be shown this as one of the options.
     1712                                                if (isset($this->all_discovered_feeds)) {
     1713                                                        $this->all_discovered_feeds[] = $file;
     1714                                                }
    15571715                                        }
     1716                                        else
     1717                                        {
     1718                                                if ($discovered)
     1719                                                {
     1720                                                        $file = $discovered;
     1721                                                }
     1722                                                else
     1723                                                {
     1724                                                        // We need to unset this so that if SimplePie::set_file() has
     1725                                                        // been called that object is untouched
     1726                                                        unset($file);
     1727                                                        $this->error = "A feed could not be found at `$this->feed_url`; the status code is `$copyStatusCode` and content-type is `$copyContentType`";
     1728                                                        $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__));
     1729                                                        return false;
     1730                                                }
     1731                                        }
    15581732                                }
    15591733                                catch (SimplePie_Exception $e)
    15601734                                {
     1735                                        // We need to unset this so that if SimplePie::set_file() has been called that object is untouched
     1736                                        unset($file);
    15611737                                        // This is usually because DOMDocument doesn't exist
    15621738                                        $this->error = $e->getMessage();
     
    15691745                                        if (!$cache->save($this))
    15701746                                        {
    1571                                                 trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
     1747                                                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);
    15721748                                        }
    15731749                                        $cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc'));
    15741750                                }
    1575                                 $this->feed_url = $file->url;
    1576                         }
     1751                        }
     1752                        $this->feed_url = $file->url;
    15771753                        $locate = null;
    15781754                }
    15791755
    15801756                $this->raw_data = $file->body;
    1581 
     1757                $this->permanent_url = $file->permanent_url;
    15821758                $headers = $file->headers;
    15831759                $sniffer = $this->registry->create('Content_Type_Sniffer', array(&$file));
     
    15881764
    15891765        /**
    1590          * Get the error message for the occurred error.
     1766         * Get the error message for the occured error
    15911767         *
    15921768         * @return string|array Error message, or array of messages for multifeeds
     
    17661942         * Get the URL for the feed
    17671943         *
    1768          * May or may not be different from the URL passed to {@see set_feed_url()},
    1769          * depending on whether auto-discovery was used.
     1944         * When the 'permanent' mode is enabled, returns the original feed URL,
     1945         * except in the case of an `HTTP 301 Moved Permanently` status response,
     1946         * in which case the location of the first redirection is returned.
     1947         *
     1948         * When the 'permanent' mode is disabled (default),
     1949         * may or may not be different from the URL passed to {@see set_feed_url()},
     1950         * depending on whether auto-discovery was used, and whether there were
     1951         * any redirects along the way.
    17701952         *
    17711953         * @since Preview Release (previously called `get_feed_url()` since SimplePie 0.8.)
    1772          * @todo If we have a perm redirect we should return the new URL
    1773          * @todo When we make the above change, let's support <itunes:new-feed-url> as well
     1954         * @todo Support <itunes:new-feed-url>
    17741955         * @todo Also, |atom:link|@rel=self
     1956         * @param bool $permanent Permanent mode to return only the original URL or the first redirection
     1957         * iff it is a 301 redirection
    17751958         * @return string|null
    17761959         */
    1777         public function subscribe_url()
    1778         {
    1779                 if ($this->feed_url !== null)
    1780                 {
    1781                         return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI);
     1960        public function subscribe_url($permanent = false)
     1961        {
     1962                if ($permanent)
     1963                {
     1964                        if ($this->permanent_url !== null)
     1965                        {
     1966                                // sanitize encodes ampersands which are required when used in a url.
     1967                                return str_replace('&amp;', '&',
     1968                                                   $this->sanitize($this->permanent_url,
     1969                                                                   SIMPLEPIE_CONSTRUCT_IRI));
     1970                        }
    17821971                }
    17831972                else
    17841973                {
    1785                         return null;
    1786                 }
     1974                        if ($this->feed_url !== null)
     1975                        {
     1976                                return str_replace('&amp;', '&',
     1977                                                   $this->sanitize($this->feed_url,
     1978                                                                   SIMPLEPIE_CONSTRUCT_IRI));
     1979                        }
     1980                }
     1981                return null;
    17871982        }
    17881983
     
    19812176                        return $this->get_link();
    19822177                }
    1983                 else
    1984                 {
    1985                         return $this->subscribe_url();
    1986                 }
     2178
     2179                return $this->subscribe_url();
    19872180        }
    19882181
     
    19992192        public function sanitize($data, $type, $base = '')
    20002193        {
    2001                 return $this->sanitize->sanitize($data, $type, $base);
     2194                try
     2195                {
     2196                        return $this->sanitize->sanitize($data, $type, $base);
     2197                }
     2198                catch (SimplePie_Exception $e)
     2199                {
     2200                        if (!$this->enable_exceptions)
     2201                        {
     2202                                $this->error = $e->getMessage();
     2203                                $this->registry->call('Misc', 'error', array($this->error, E_USER_WARNING, $e->getFile(), $e->getLine()));
     2204                                return '';
     2205                        }
     2206
     2207                        throw $e;
     2208                }
    20022209        }
    20032210
     
    20402247                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    20412248                }
    2042                 else
    2043                 {
    2044                         return null;
    2045                 }
     2249
     2250                return null;
    20462251        }
    20472252
     
    20502255         *
    20512256         * @since Unknown
    2052          * @param int $key The category that you want to return.  Remember that arrays begin with 0, not 1
     2257         * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1
    20532258         * @return SimplePie_Category|null
    20542259         */
     
    20602265                        return $categories[$key];
    20612266                }
    2062                 else
    2063                 {
    2064                         return null;
    2065                 }
     2267
     2268                return null;
    20662269        }
    20672270
     
    21252328                        return array_unique($categories);
    21262329                }
    2127                 else
    2128                 {
    2129                         return null;
    2130                 }
     2330
     2331                return null;
    21312332        }
    21322333
     
    21352336         *
    21362337         * @since 1.1
    2137          * @param int $key The author that you want to return.  Remember that arrays begin with 0, not 1
     2338         * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1
    21382339         * @return SimplePie_Author|null
    21392340         */
     
    21452346                        return $authors[$key];
    21462347                }
    2147                 else
    2148                 {
    2149                         return null;
    2150                 }
     2348
     2349                return null;
    21512350        }
    21522351
     
    22232422                        return array_unique($authors);
    22242423                }
    2225                 else
    2226                 {
    2227                         return null;
    2228                 }
     2424
     2425                return null;
    22292426        }
    22302427
     
    22332430         *
    22342431         * @since 1.1
    2235          * @param int $key The contrbutor that you want to return.  Remember that arrays begin with 0, not 1
     2432         * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1
    22362433         * @return SimplePie_Author|null
    22372434         */
     
    22432440                        return $contributors[$key];
    22442441                }
    2245                 else
    2246                 {
    2247                         return null;
    2248                 }
     2442
     2443                return null;
    22492444        }
    22502445
     
    23092504                        return array_unique($contributors);
    23102505                }
    2311                 else
    2312                 {
    2313                         return null;
    2314                 }
     2506
     2507                return null;
    23152508        }
    23162509
     
    23192512         *
    23202513         * @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8)
    2321          * @param int $key The link that you want to return.  Remember that arrays begin with 0, not 1
     2514         * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1
    23222515         * @param string $rel The relationship of the link to return
    23232516         * @return string|null Link URL
     
    23302523                        return $links[$key];
    23312524                }
    2332                 else
    2333                 {
    2334                         return null;
    2335                 }
     2525
     2526                return null;
    23362527        }
    23372528
     
    24252616                }
    24262617
    2427                 if (isset($this->data['links'][$rel]))
     2618                if (isset($this->data['headers']['link']) &&
     2619                    preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/',
     2620                               $this->data['headers']['link'], $match))
     2621                {
     2622                        return array($match[1]);
     2623                }
     2624                else if (isset($this->data['links'][$rel]))
    24282625                {
    24292626                        return $this->data['links'][$rel];
    24302627                }
    2431                 else
    2432                 {
    2433                         return null;
    2434                 }
     2628
     2629                return null;
    24352630        }
    24362631
     
    24872682                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0]));
    24882683                }
    2489                 else
    2490                 {
    2491                         return null;
    2492                 }
     2684
     2685                return null;
    24932686        }
    24942687
     
    25232716                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    25242717                }
    2525                 else
    2526                 {
    2527                         return null;
    2528                 }
     2718
     2719                return null;
    25292720        }
    25302721
     
    25672758                        return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT);
    25682759                }
    2569                 else
    2570                 {
    2571                         return null;
    2572                 }
     2760
     2761                return null;
    25732762        }
    25742763
     
    25962785                        return (float) $match[1];
    25972786                }
    2598                 else
    2599                 {
    2600                         return null;
    2601                 }
     2787
     2788                return null;
    26022789        }
    26032790
     
    26282815                        return (float) $match[2];
    26292816                }
    2630                 else
    2631                 {
    2632                         return null;
    2633                 }
     2817
     2818                return null;
    26342819        }
    26352820
     
    26652850                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
    26662851                }
    2667                 else
    2668                 {
    2669                         return null;
    2670                 }
     2852
     2853                return null;
    26712854        }
    26722855
     
    27082891                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
    27092892                }
    2710                 else
    2711                 {
    2712                         return null;
    2713                 }
     2893
     2894                return null;
    27142895        }
    27152896
     
    27402921                        return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
    27412922                }
    2742                 else
    2743                 {
    2744                         return null;
    2745                 }
     2923
     2924                return null;
    27462925        }
    27472926
     
    27662945                        return 88.0;
    27672946                }
    2768                 else
    2769                 {
    2770                         return null;
    2771                 }
     2947
     2948                return null;
    27722949        }
    27732950
     
    27922969                        return 31.0;
    27932970                }
    2794                 else
    2795                 {
    2796                         return null;
    2797                 }
     2971
     2972                return null;
    27982973        }
    27992974
     
    28152990                        return $qty;
    28162991                }
    2817                 else
    2818                 {
    2819                         return ($qty > $max) ? $max : $qty;
    2820                 }
     2992
     2993                return ($qty > $max) ? $max : $qty;
    28212994        }
    28222995
     
    28303003         * @see get_item_quantity()
    28313004         * @since Beta 2
    2832          * @param int $key The item that you want to return.  Remember that arrays begin with 0, not 1
     3005         * @param int $key The item that you want to return. Remember that arrays begin with 0, not 1
    28333006         * @return SimplePie_Item|null
    28343007         */
     
    28403013                        return $items[$key];
    28413014                }
    2842                 else
    2843                 {
    2844                         return null;
    2845                 }
     3015
     3016                return null;
    28463017        }
    28473018
     
    28573028         * @param int $start Index to start at
    28583029         * @param int $end Number of items to return. 0 for all items after `$start`
    2859          * @return array|null List of {@see SimplePie_Item} objects
     3030         * @return SimplePie_Item[]|null List of {@see SimplePie_Item} objects
    28603031         */
    28613032        public function get_items($start = 0, $end = 0)
     
    28663037                        {
    28673038                                $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
    2868                         }
    2869                         else
    2870                         {
    2871                                 $this->data['items'] = array();
    2872                                 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
    2873                                 {
    2874                                         $keys = array_keys($items);
    2875                                         foreach ($keys as $key)
    2876                                         {
    2877                                                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
    2878                                         }
    2879                                 }
    2880                                 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
    2881                                 {
    2882                                         $keys = array_keys($items);
    2883                                         foreach ($keys as $key)
    2884                                         {
    2885                                                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
    2886                                         }
    2887                                 }
    2888                                 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
    2889                                 {
    2890                                         $keys = array_keys($items);
    2891                                         foreach ($keys as $key)
    2892                                         {
    2893                                                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
    2894                                         }
    2895                                 }
    2896                                 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
    2897                                 {
    2898                                         $keys = array_keys($items);
    2899                                         foreach ($keys as $key)
    2900                                         {
    2901                                                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
    2902                                         }
    2903                                 }
    2904                                 if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item'))
    2905                                 {
    2906                                         $keys = array_keys($items);
    2907                                         foreach ($keys as $key)
    2908                                         {
    2909                                                 $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
    2910                                         }
    2911                                 }
    2912                         }
    2913                 }
    2914 
    2915                 if (!empty($this->data['items']))
    2916                 {
    2917                         // If we want to order it by date, check if all items have a date, and then sort it
    2918                         if ($this->order_by_date && empty($this->multifeed_objects))
    2919                         {
    2920                                 if (!isset($this->data['ordered_items']))
    2921                                 {
    2922                                         $do_sort = true;
    2923                                         foreach ($this->data['items'] as $item)
    2924                                         {
    2925                                                 if (!$item->get_date('U'))
    2926                                                 {
    2927                                                         $do_sort = false;
    2928                                                         break;
    2929                                                 }
    2930                                         }
    2931                                         $item = null;
    2932                                         $this->data['ordered_items'] = $this->data['items'];
    2933                                         if ($do_sort)
    2934                                         {
    2935                                                 usort($this->data['ordered_items'], array(get_class($this), 'sort_items'));
    2936                                         }
    2937                                 }
    2938                                 $items = $this->data['ordered_items'];
    2939                         }
    2940                         else
    2941                         {
    2942                                 $items = $this->data['items'];
    2943                         }
    2944 
    2945                         // Slice the data as desired
    2946                         if ($end === 0)
    2947                         {
    2948                                 return array_slice($items, $start);
    2949                         }
    2950                         else
    2951                         {
    2952                                 return array_slice($items, $start, $end);
    2953                         }
     3039                                if (empty($this->data['items']))
     3040                                {
     3041                                        return array();
     3042                                }
     3043                                return $this->data['items'];
     3044                        }
     3045                        $this->data['items'] = array();
     3046                        if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
     3047                        {
     3048                                $keys = array_keys($items);
     3049                                foreach ($keys as $key)
     3050                                {
     3051                                        $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
     3052                                }
     3053                        }
     3054                        if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
     3055                        {
     3056                                $keys = array_keys($items);
     3057                                foreach ($keys as $key)
     3058                                {
     3059                                        $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
     3060                                }
     3061                        }
     3062                        if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
     3063                        {
     3064                                $keys = array_keys($items);
     3065                                foreach ($keys as $key)
     3066                                {
     3067                                        $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
     3068                                }
     3069                        }
     3070                        if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
     3071                        {
     3072                                $keys = array_keys($items);
     3073                                foreach ($keys as $key)
     3074                                {
     3075                                        $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
     3076                                }
     3077                        }
     3078                        if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item'))
     3079                        {
     3080                                $keys = array_keys($items);
     3081                                foreach ($keys as $key)
     3082                                {
     3083                                        $this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
     3084                                }
     3085                        }
     3086                }
     3087
     3088                if (empty($this->data['items']))
     3089                {
     3090                        return array();
     3091                }
     3092
     3093                if ($this->order_by_date)
     3094                {
     3095                        if (!isset($this->data['ordered_items']))
     3096                        {
     3097                                $this->data['ordered_items'] = $this->data['items'];
     3098                                usort($this->data['ordered_items'], array(get_class($this), 'sort_items'));
     3099                        }
     3100                        $items = $this->data['ordered_items'];
    29543101                }
    29553102                else
    29563103                {
    2957                         return array();
    2958                 }
     3104                        $items = $this->data['items'];
     3105                }
     3106                // Slice the data as desired
     3107                if ($end === 0)
     3108                {
     3109                        return array_slice($items, $start);
     3110                }
     3111
     3112                return array_slice($items, $start, $end);
    29593113        }
    29603114
     
    29833137                if (($url = $this->get_link()) !== null)
    29843138                {
    2985                         return 'http://g.etfv.co/' . urlencode($url);
     3139                        return 'https://www.google.com/s2/favicons?domain=' . urlencode($url);
    29863140                }
    29873141
     
    30283182        public static function sort_items($a, $b)
    30293183        {
    3030                 return $a->get_date('U') <= $b->get_date('U');
     3184                $a_date = $a->get_date('U');
     3185                $b_date = $b->get_date('U');
     3186                if ($a_date && $b_date) {
     3187                        return $a_date > $b_date ? -1 : 1;
     3188                }
     3189                // Sort items without dates to the top.
     3190                if ($a_date) {
     3191                        return 1;
     3192                }
     3193                if ($b_date) {
     3194                        return -1;
     3195                }
     3196                return 0;
    30313197        }
    30323198
     
    30613227                        }
    30623228
    3063                         $do_sort = true;
    3064                         foreach ($items as $item)
    3065                         {
    3066                                 if (!$item->get_date('U'))
    3067                                 {
    3068                                         $do_sort = false;
    3069                                         break;
    3070                                 }
    3071                         }
    3072                         $item = null;
    3073                         if ($do_sort)
    3074                         {
    3075                                 usort($items, array(get_class($urls[0]), 'sort_items'));
    3076                         }
     3229                        usort($items, array(get_class($urls[0]), 'sort_items'));
    30773230
    30783231                        if ($end === 0)
     
    30803233                                return array_slice($items, $start);
    30813234                        }
     3235
     3236                        return array_slice($items, $start, $end);
     3237                }
     3238
     3239                trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING);
     3240                return array();
     3241        }
     3242
     3243        /**
     3244         * Store PubSubHubbub links as headers
     3245         *
     3246         * There is no way to find PuSH links in the body of a microformats feed,
     3247         * so they are added to the headers when found, to be used later by get_links.
     3248         * @param SimplePie_File $file
     3249         * @param string $hub
     3250         * @param string $self
     3251         */
     3252        private function store_links(&$file, $hub, $self) {
     3253                if (isset($file->headers['link']['hub']) ||
     3254                          (isset($file->headers['link']) &&
     3255                           preg_match('/rel=hub/', $file->headers['link'])))
     3256                {
     3257                        return;
     3258                }
     3259
     3260                if ($hub)
     3261                {
     3262                        if (isset($file->headers['link']))
     3263                        {
     3264                                if ($file->headers['link'] !== '')
     3265                                {
     3266                                        $file->headers['link'] = ', ';
     3267                                }
     3268                        }
    30823269                        else
    30833270                        {
    3084                                 return array_slice($items, $start, $end);
    3085                         }
    3086                 }
    3087                 else
    3088                 {
    3089                         trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING);
    3090                         return array();
     3271                                $file->headers['link'] = '';
     3272                        }
     3273                        $file->headers['link'] .= '<'.$hub.'>; rel=hub';
     3274                        if ($self)
     3275                        {
     3276                                $file->headers['link'] .= ', <'.$self.'>; rel=self';
     3277                        }
    30913278                }
    30923279        }
Note: See TracChangeset for help on using the changeset viewer.