--- a/wp/wp-includes/SimplePie/IRI.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/SimplePie/IRI.php Tue Dec 15 13:49:49 2020 +0100
@@ -5,7 +5,7 @@
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
- * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
+ * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
@@ -33,10 +33,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
- * @version 1.3.1
- * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
+ * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
- * @author Geoffrey Sneddon
+ * @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
@@ -47,10 +46,10 @@
*
* @package SimplePie
* @subpackage HTTP
- * @author Geoffrey Sneddon
+ * @author Sam Sneddon
* @author Steve Minutillo
* @author Ryan McCue
- * @copyright 2007-2012 Geoffrey Sneddon, Steve Minutillo, Ryan McCue
+ * @copyright 2007-2012 Sam Sneddon, Steve Minutillo, Ryan McCue
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class SimplePie_IRI
@@ -212,10 +211,8 @@
{
return $this->normalization[$this->scheme][$name];
}
- else
- {
- return $return;
- }
+
+ return $return;
}
/**
@@ -226,14 +223,7 @@
*/
public function __isset($name)
{
- if (method_exists($this, 'get_' . $name) || isset($this->$name))
- {
- return true;
- }
- else
- {
- return false;
- }
+ return method_exists($this, 'get_' . $name) || isset($this->$name);
}
/**
@@ -260,6 +250,15 @@
}
/**
+ * Clean up
+ */
+ public function __destruct() {
+ $this->set_iri(null, true);
+ $this->set_path(null, true);
+ $this->set_authority(null, true);
+ }
+
+ /**
* Create a new IRI object by resolving a relative IRI
*
* Returns false if $base is not absolute, otherwise an IRI.
@@ -348,10 +347,8 @@
$target->scheme_normalization();
return $target;
}
- else
- {
- return false;
- }
+
+ return false;
}
}
@@ -388,11 +385,9 @@
}
return $match;
}
- else
- {
- // This can occur when a paragraph is accidentally parsed as a URI
- return false;
- }
+
+ // This can occur when a paragraph is accidentally parsed as a URI
+ return false;
}
/**
@@ -768,24 +763,20 @@
*/
public function is_valid()
{
- $isauthority = $this->iuserinfo !== null || $this->ihost !== null || $this->port !== null;
- if ($this->ipath !== '' &&
- (
- $isauthority && (
- $this->ipath[0] !== '/' ||
- substr($this->ipath, 0, 2) === '//'
- ) ||
- (
- $this->scheme === null &&
- !$isauthority &&
- strpos($this->ipath, ':') !== false &&
- (strpos($this->ipath, '/') === false ? true : strpos($this->ipath, ':') < strpos($this->ipath, '/'))
- )
- )
- )
- {
- return false;
- }
+ if ($this->ipath === '') return true;
+
+ $isauthority = $this->iuserinfo !== null || $this->ihost !== null ||
+ $this->port !== null;
+ if ($isauthority && $this->ipath[0] === '/') return true;
+
+ if (!$isauthority && (substr($this->ipath, 0, 2) === '//')) return false;
+
+ // Relative urls cannot have a colon in the first path segment (and the
+ // slashes themselves are not included so skip the first character).
+ if (!$this->scheme && !$isauthority &&
+ strpos($this->ipath, ':') !== false &&
+ strpos($this->ipath, '/', 1) !== false &&
+ strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false;
return true;
}
@@ -797,9 +788,14 @@
* @param string $iri
* @return bool
*/
- public function set_iri($iri)
+ public function set_iri($iri, $clear_cache = false)
{
static $cache;
+ if ($clear_cache)
+ {
+ $cache = null;
+ return;
+ }
if (!$cache)
{
$cache = array();
@@ -821,30 +817,28 @@
$return) = $cache[$iri];
return $return;
}
- else
+
+ $parsed = $this->parse_iri((string) $iri);
+ if (!$parsed)
{
- $parsed = $this->parse_iri((string) $iri);
- if (!$parsed)
- {
- return false;
- }
+ return false;
+ }
- $return = $this->set_scheme($parsed['scheme'])
- && $this->set_authority($parsed['authority'])
- && $this->set_path($parsed['path'])
- && $this->set_query($parsed['query'])
- && $this->set_fragment($parsed['fragment']);
+ $return = $this->set_scheme($parsed['scheme'])
+ && $this->set_authority($parsed['authority'])
+ && $this->set_path($parsed['path'])
+ && $this->set_query($parsed['query'])
+ && $this->set_fragment($parsed['fragment']);
- $cache[$iri] = array($this->scheme,
- $this->iuserinfo,
- $this->ihost,
- $this->port,
- $this->ipath,
- $this->iquery,
- $this->ifragment,
- $return);
- return $return;
- }
+ $cache[$iri] = array($this->scheme,
+ $this->iuserinfo,
+ $this->ihost,
+ $this->port,
+ $this->ipath,
+ $this->iquery,
+ $this->ifragment,
+ $return);
+ return $return;
}
/**
@@ -879,9 +873,14 @@
* @param string $authority
* @return bool
*/
- public function set_authority($authority)
+ public function set_authority($authority, $clear_cache = false)
{
static $cache;
+ if ($clear_cache)
+ {
+ $cache = null;
+ return;
+ }
if (!$cache)
$cache = array();
@@ -901,42 +900,40 @@
return $return;
}
+
+ $remaining = $authority;
+ if (($iuserinfo_end = strrpos($remaining, '@')) !== false)
+ {
+ $iuserinfo = substr($remaining, 0, $iuserinfo_end);
+ $remaining = substr($remaining, $iuserinfo_end + 1);
+ }
else
{
- $remaining = $authority;
- if (($iuserinfo_end = strrpos($remaining, '@')) !== false)
- {
- $iuserinfo = substr($remaining, 0, $iuserinfo_end);
- $remaining = substr($remaining, $iuserinfo_end + 1);
- }
- else
- {
- $iuserinfo = null;
- }
- if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false)
- {
- if (($port = substr($remaining, $port_start + 1)) === false)
- {
- $port = null;
- }
- $remaining = substr($remaining, 0, $port_start);
- }
- else
+ $iuserinfo = null;
+ }
+ if (($port_start = strpos($remaining, ':', strpos($remaining, ']'))) !== false)
+ {
+ if (($port = substr($remaining, $port_start + 1)) === false)
{
$port = null;
}
-
- $return = $this->set_userinfo($iuserinfo) &&
- $this->set_host($remaining) &&
- $this->set_port($port);
+ $remaining = substr($remaining, 0, $port_start);
+ }
+ else
+ {
+ $port = null;
+ }
- $cache[$authority] = array($this->iuserinfo,
- $this->ihost,
- $this->port,
- $return);
+ $return = $this->set_userinfo($iuserinfo) &&
+ $this->set_host($remaining) &&
+ $this->set_port($port);
- return $return;
- }
+ $cache[$authority] = array($this->iuserinfo,
+ $this->ihost,
+ $this->port,
+ $return);
+
+ return $return;
}
/**
@@ -1036,11 +1033,9 @@
$this->scheme_normalization();
return true;
}
- else
- {
- $this->port = null;
- return false;
- }
+
+ $this->port = null;
+ return false;
}
/**
@@ -1049,9 +1044,14 @@
* @param string $ipath
* @return bool
*/
- public function set_path($ipath)
+ public function set_path($ipath, $clear_cache = false)
{
static $cache;
+ if ($clear_cache)
+ {
+ $cache = null;
+ return;
+ }
if (!$cache)
{
$cache = array();
@@ -1166,7 +1166,7 @@
{
$iri .= $this->ipath;
}
- elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '')
+ elseif (!empty($this->normalization[$this->scheme]['ipath']) && $iauthority !== null && $iauthority !== '')
{
$iri .= $this->normalization[$this->scheme]['ipath'];
}
@@ -1210,16 +1210,14 @@
{
$iauthority .= $this->ihost;
}
- if ($this->port !== null)
+ if ($this->port !== null && $this->port !== 0)
{
$iauthority .= ':' . $this->port;
}
return $iauthority;
}
- else
- {
- return null;
- }
+
+ return null;
}
/**
@@ -1232,7 +1230,7 @@
$iauthority = $this->get_iauthority();
if (is_string($iauthority))
return $this->to_uri($iauthority);
- else
- return $iauthority;
+
+ return $iauthority;
}
}