Fixed a bug where PUC might not properly whitelist the hostname used in the metadata URL if there were at least two active plugins using the same version of PUC.
This commit is contained in:
parent
28f29c940c
commit
5cdadd0369
|
|
@ -60,6 +60,11 @@ if ( !class_exists('Puc_v4p9_UpdateChecker', false) ):
|
|||
*/
|
||||
protected $lastRequestApiErrors = array();
|
||||
|
||||
/**
|
||||
* @var string|mixed The default is 0 because parse_url() can return NULL or FALSE.
|
||||
*/
|
||||
protected $cachedMetadataHost = 0;
|
||||
|
||||
public function __construct($metadataUrl, $directoryName, $slug = null, $checkPeriod = 12, $optionName = '') {
|
||||
$this->debugMode = (bool)(constant('WP_DEBUG'));
|
||||
$this->metadataUrl = $metadataUrl;
|
||||
|
|
@ -187,12 +192,11 @@ if ( !class_exists('Puc_v4p9_UpdateChecker', false) ):
|
|||
* @return bool
|
||||
*/
|
||||
public function allowMetadataHost($allow, $host) {
|
||||
static $metadataHost = 0; //Using 0 instead of NULL because parse_url can return NULL.
|
||||
if ( $metadataHost === 0 ) {
|
||||
$metadataHost = parse_url($this->metadataUrl, PHP_URL_HOST);
|
||||
if ( $this->cachedMetadataHost === 0 ) {
|
||||
$this->cachedMetadataHost = parse_url($this->metadataUrl, PHP_URL_HOST);
|
||||
}
|
||||
|
||||
if ( is_string($metadataHost) && (strtolower($host) === strtolower($metadataHost)) ) {
|
||||
if ( is_string($this->cachedMetadataHost) && (strtolower($host) === strtolower($this->cachedMetadataHost)) ) {
|
||||
return true;
|
||||
}
|
||||
return $allow;
|
||||
|
|
|
|||
Loading…
Reference in New Issue