Make WordPress Core


Ignore:
Timestamp:
09/16/2025 10:45:37 PM (2 months ago)
Author:
SergeyBiryukov
Message:

External Libraries: Update the SimplePie library to version 1.9.0.

References:

Follow-up to [59141], [60490].

Props swissspidy, TobiasBg, SergeyBiryukov.
Fixes #63961.

File:
1 edited

Legend:

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

    r59141 r60771  
    11<?php
    22
    3 /**
    4  * SimplePie
    5  *
    6  * A PHP-Based RSS and Atom Feed Framework.
    7  * Takes the hard work out of managing a complete RSS/Atom solution.
    8  *
    9  * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
    10  * All rights reserved.
    11  *
    12  * Redistribution and use in source and binary forms, with or without modification, are
    13  * permitted provided that the following conditions are met:
    14  *
    15  *  * Redistributions of source code must retain the above copyright notice, this list of
    16  *    conditions and the following disclaimer.
    17  *
    18  *  * Redistributions in binary form must reproduce the above copyright notice, this list
    19  *    of conditions and the following disclaimer in the documentation and/or other materials
    20  *    provided with the distribution.
    21  *
    22  *  * Neither the name of the SimplePie Team nor the names of its contributors may be used
    23  *    to endorse or promote products derived from this software without specific prior
    24  *    written permission.
    25  *
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
    27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    28  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
    29  * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    33  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    34  * POSSIBILITY OF SUCH DAMAGE.
    35  *
    36  * @package SimplePie
    37  * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
    38  * @author Ryan Parman
    39  * @author Sam Sneddon
    40  * @author Ryan McCue
    41  * @link http://simplepie.org/ SimplePie
    42  * @license http://www.opensource.org/licenses/bsd-license.php BSD License
    43  */
     3// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
     4// SPDX-License-Identifier: BSD-3-Clause
     5
     6declare(strict_types=1);
    447
    458namespace SimplePie;
     
    5114 *
    5215 * This class can be overloaded with {@see \SimplePie::set_source_class()}
    53  *
    54  * @package SimplePie
    55  * @subpackage API
    5616 */
    5717class Source implements RegistryAware
    5818{
     19    /** @var Item */
    5920    public $item;
     21    /** @var array<string, mixed> */
    6022    public $data = [];
     23    /** @var Registry */
    6124    protected $registry;
    6225
    63     public function __construct($item, $data)
     26    /**
     27     * @param array<string, mixed> $data
     28     */
     29    public function __construct(Item $item, array $data)
    6430    {
    6531        $this->item = $item;
     
    6733    }
    6834
    69     public function set_registry(\SimplePie\Registry $registry)/* : void */
     35    /**
     36     * @return void
     37     */
     38    public function set_registry(\SimplePie\Registry $registry)
    7039    {
    7140        $this->registry = $registry;
    7241    }
    7342
     43    /**
     44     * @return string
     45     */
    7446    public function __toString()
    7547    {
     
    7749    }
    7850
    79     public function get_source_tags($namespace, $tag)
     51    /**
     52     * @param string $namespace
     53     * @param string $tag
     54     * @return array<array<string, mixed>>|null
     55     */
     56    public function get_source_tags(string $namespace, string $tag)
    8057    {
    8158        if (isset($this->data['child'][$namespace][$tag])) {
     
    8663    }
    8764
    88     public function get_base($element = [])
     65    /**
     66     * @param array<string, mixed> $element
     67     * @return string
     68     */
     69    public function get_base(array $element = [])
    8970    {
    9071        return $this->item->get_base($element);
    9172    }
    9273
    93     public function sanitize($data, $type, $base = '')
     74    /**
     75     * @param string $data
     76     * @param int-mask-of<SimplePie::CONSTRUCT_*> $type
     77     * @param string $base
     78     * @return string
     79     */
     80    public function sanitize(string $data, $type, string $base = '')
    9481    {
    9582        return $this->item->sanitize($data, $type, $base);
    9683    }
    9784
     85    /**
     86     * @return Item
     87     */
    9888    public function get_item()
    9989    {
     
    10191    }
    10292
     93    /**
     94     * @return string|null
     95     */
    10396    public function get_title()
    10497    {
     
    122115    }
    123116
    124     public function get_category($key = 0)
     117    /**
     118     * @param int $key
     119     * @return Category|null
     120     */
     121    public function get_category(int $key = 0)
    125122    {
    126123        $categories = $this->get_categories();
     
    132129    }
    133130
     131    /**
     132     * @return array<Category>|null
     133     */
    134134    public function get_categories()
    135135    {
     
    176176    }
    177177
    178     public function get_author($key = 0)
     178    /**
     179     * @param int $key
     180     * @return Author|null
     181     */
     182    public function get_author(int $key = 0)
    179183    {
    180184        $authors = $this->get_authors();
     
    186190    }
    187191
     192    /**
     193     * @return array<Author>|null
     194     */
    188195    public function get_authors()
    189196    {
     
    197204            }
    198205            if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
    199                 $uri = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]));
     206                $uri = $author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
     207                $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
    200208            }
    201209            if (isset($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
     
    214222            }
    215223            if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
    216                 $url = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]));
     224                $url = $author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
     225                $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
    217226            }
    218227            if (isset($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
     
    240249    }
    241250
    242     public function get_contributor($key = 0)
     251    /**
     252     * @param int $key
     253     * @return Author|null
     254     */
     255    public function get_contributor(int $key = 0)
    243256    {
    244257        $contributors = $this->get_contributors();
     
    250263    }
    251264
     265    /**
     266     * @return array<Author>|null
     267     */
    252268    public function get_contributors()
    253269    {
     
    261277            }
    262278            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
    263                 $uri = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0]));
     279                $uri = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['uri'][0];
     280                $uri = $this->sanitize($uri['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($uri));
    264281            }
    265282            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'])) {
     
    278295            }
    279296            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'])) {
    280                 $url = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0]));
     297                $url = $contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['url'][0];
     298                $url = $this->sanitize($url['data'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($url));
    281299            }
    282300            if (isset($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'])) {
     
    295313    }
    296314
    297     public function get_link($key = 0, $rel = 'alternate')
     315    /**
     316     * @param int $key
     317     * @param string $rel
     318     * @return string|null
     319     */
     320    public function get_link(int $key = 0, string $rel = 'alternate')
    298321    {
    299322        $links = $this->get_links($rel);
     
    307330    /**
    308331     * Added for parity between the parent-level and the item/entry-level.
     332     *
     333     * @return string|null
    309334     */
    310335    public function get_permalink()
     
    313338    }
    314339
    315     public function get_links($rel = 'alternate')
     340    /**
     341     * @param string $rel
     342     * @return array<string>|null
     343     */
     344    public function get_links(string $rel = 'alternate')
    316345    {
    317346        if (!isset($this->data['links'])) {
     
    345374            $keys = array_keys($this->data['links']);
    346375            foreach ($keys as $key) {
     376                $key = (string) $key;
     377
    347378                if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
    348379                    if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) {
     
    366397    }
    367398
     399    /**
     400     * @return string|null
     401     */
    368402    public function get_description()
    369403    {
     
    391425    }
    392426
     427    /**
     428     * @return string|null
     429     */
    393430    public function get_copyright()
    394431    {
     
    408445    }
    409446
     447    /**
     448     * @return string|null
     449     */
    410450    public function get_language()
    411451    {
     
    423463    }
    424464
     465    /**
     466     * @return float|null
     467     */
    425468    public function get_latitude()
    426469    {
     
    434477    }
    435478
     479    /**
     480     * @return float|null
     481     */
    436482    public function get_longitude()
    437483    {
     
    447493    }
    448494
     495    /**
     496     * @return string|null
     497     */
    449498    public function get_image_url()
    450499    {
Note: See TracChangeset for help on using the changeset viewer.