Fix feed discovery: html:link@rel can contain multiple values; saw rel="updates alternate" in the wild at http://tantek.com/ which broke old discovery code.

This commit is contained in:
Brion Vibber 2010-03-15 20:26:42 +00:00
parent c9232d8f26
commit dfac4bfd09

View File

@ -211,11 +211,11 @@ class FeedDiscovery
$type = $node->attributes->getNamedItem('type'); $type = $node->attributes->getNamedItem('type');
$href = $node->attributes->getNamedItem('href'); $href = $node->attributes->getNamedItem('href');
if ($rel && $type && $href) { if ($rel && $type && $href) {
$rel = trim($rel->value); $rel = array_filter(explode(" ", $rel->value));
$type = trim($type->value); $type = trim($type->value);
$href = trim($href->value); $href = trim($href->value);
if (trim($rel) == 'alternate' && array_key_exists($type, $feeds) && empty($feeds[$type])) { if (in_array('alternate', $rel) && array_key_exists($type, $feeds) && empty($feeds[$type])) {
// Save the first feed found of each type... // Save the first feed found of each type...
$feeds[$type] = $this->resolveURI($href, $base); $feeds[$type] = $this->resolveURI($href, $base);
} }