Skip to content

Commit

Permalink
Check if the Sanitize class has been changed and update the registry. (
Browse files Browse the repository at this point in the history
…#532)

* Check if the Sanitize class has been changed and update the registry.

* Also preference links in the headers over links in the body to comply with WebSub specification.
  • Loading branch information
mblaney committed Jul 28, 2017
1 parent 3997527 commit 2a0670a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions library/SimplePie.php
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,11 @@ public function init()
}
}

// The default sanitize class gets set in the constructor, check if it has
// changed.
if ($this->registry->get_class('Sanitize') !== 'SimplePie_Sanitize') {
$this->sanitize = $this->registry->create('Sanitize');
}
if (method_exists($this->sanitize, 'set_registry'))
{
$this->sanitize->set_registry($this->registry);
Expand Down Expand Up @@ -2606,15 +2611,15 @@ public function get_links($rel = 'alternate')
}
}

if (isset($this->data['links'][$rel]))
if (isset($this->data['headers']['link']) &&
preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/',
$this->data['headers']['link'], $match))
{
return $this->data['links'][$rel];
return array($match[1]);
}
else if (isset($this->data['headers']['link']) &&
preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/',
$this->data['headers']['link'], $match))
else if (isset($this->data['links'][$rel]))
{
return array($match[1]);
return $this->data['links'][$rel];
}
else
{
Expand Down

0 comments on commit 2a0670a

Please sign in to comment.