Make WordPress Core


Ignore:
Timestamp:
12/20/2021 07:31:37 PM (3 years ago)
Author:
SergeyBiryukov
Message:

External Libraries: Update the SimplePie library to version 1.5.7.

This version shows significant improvements in the compatibility of SimplePie with PHP 8.0, 8.1, and even contains an initial PHP 8.2 fix. The release also contains a number of other bug fixes.

Release notes: https://github.com/simplepie/simplepie/releases/tag/1.5.7

For a full list of changes in this update, see the SimplePie GitHub:
https://github.com/simplepie/simplepie/compare/1.5.6...1.5.7

Follow-up to [47733], [49176].

Props jrf, SergeyBiryukov.
Fixes #54659.

File:
1 edited

Legend:

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

    r47733 r52393  
    7272    var $force_fsockopen = false;
    7373    var $replace_url_attributes = null;
     74    var $registry;
     75
     76    /**
     77     * List of domains for which to force HTTPS.
     78     * @see SimplePie_Sanitize::set_https_domains()
     79     * Array is a tree split at DNS levels. Example:
     80     * array('biz' => true, 'com' => array('example' => true), 'net' => array('example' => array('www' => true)))
     81     */
     82    var $https_domains = array();
    7483
    7584    public function __construct()
     
    242251    }
    243252
     253    /**
     254     * Set the list of domains for which to force HTTPS.
     255     * @see SimplePie_Misc::https_url()
     256     * Example array('biz', 'example.com', 'example.org', 'www.example.net');
     257     */
     258    public function set_https_domains($domains)
     259    {
     260        $this->https_domains = array();
     261        foreach ($domains as $domain)
     262        {
     263            $domain = trim($domain, ". \t\n\r\0\x0B");
     264            $segments = array_reverse(explode('.', $domain));
     265            $node =& $this->https_domains;
     266            foreach ($segments as $segment)
     267            {//Build a tree
     268                if ($node === true)
     269                {
     270                    break;
     271                }
     272                if (!isset($node[$segment]))
     273                {
     274                    $node[$segment] = array();
     275                }
     276                $node =& $node[$segment];
     277            }
     278            $node = true;
     279        }
     280    }
     281
     282    /**
     283     * Check if the domain is in the list of forced HTTPS.
     284     */
     285    protected function is_https_domain($domain)
     286    {
     287        $domain = trim($domain, '. ');
     288        $segments = array_reverse(explode('.', $domain));
     289        $node =& $this->https_domains;
     290        foreach ($segments as $segment)
     291        {//Explore the tree
     292            if (isset($node[$segment]))
     293            {
     294                $node =& $node[$segment];
     295            }
     296            else
     297            {
     298                break;
     299            }
     300        }
     301        return $node === true;
     302    }
     303
     304    /**
     305     * Force HTTPS for selected Web sites.
     306     */
     307    public function https_url($url)
     308    {
     309        return (strtolower(substr($url, 0, 7)) === 'http://') &&
     310            $this->is_https_domain(parse_url($url, PHP_URL_HOST)) ?
     311            substr_replace($url, 's', 4, 0) :   //Add the 's' to HTTPS
     312            $url;
     313    }
     314
    244315    public function sanitize($data, $type, $base = '')
    245316    {
     
    444515                        if ($value !== false)
    445516                        {
     517                            $value = $this->https_url($value);
    446518                            $element->setAttribute($attribute, $value);
    447519                        }
Note: See TracChangeset for help on using the changeset viewer.