static function resolve_relative_uris($content, $obj)
{
$set = $obj->link->setting('resolve relative', 'resolve_relative', 'yes');
if ($set and $set != 'no') {
// Fallback: if we don't have anything better, use the
// item link from the feed
$obj->_base = $obj->permalink();
// Reset the base for resolving relative URIs
// What we should do here, properly, is to use
// SimplePie_Item::get_base() -- but that method is
// currently broken. Or getting down and dirty in the
// SimplePie representation of the content tags and
// grabbing the xml_base member for the content element.
// Maybe someday...
foreach ($obj->uri_attrs as $pair) {
list($tag, $attr) = $pair;
$pattern = FeedWordPressHTML::attributeRegex($tag, $attr);
// FIXME: Encountered issue while testing an extremely long (= 88827 characters) item
// Relying on preg_replace_callback() here can cause a PHP seg fault on my development
// server. preg_match_all() causes a similar problem. Apparently this is a PCRE issue
// Cf. discussion of similar issue <https://bugs.php.net/bug.php?id=65009>
$content = preg_replace_callback($pattern, array($obj, 'resolve_single_relative_uri'), $content);
}
}
return $content;
}