WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/01/2020 02:24:42 PM (18 months 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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';
Note: See TracChangeset for help on using the changeset viewer.