⬆️ Update SimplePie library.

As a follow up to issue #699 update SimplePie from 1.2.1-dev (around
6years old) to current git master (1.4.4-dev). We use the master branch
until the next release because it contains our patch for enclosure
titles already. The other patches in the library from us can be done by
configuring the SimplePie object in our code instead.
Used composer to manage this library and use class autoloading.
Add some unit tests for include/feedutils.php, but the interesting parts
are unfortunately not testable with the current code.
This commit is contained in:
Klaus Weidenbach
2017-04-03 22:08:32 +02:00
parent b4f65840d1
commit b6459e6172
59 changed files with 21038 additions and 15888 deletions

View File

@@ -1078,7 +1078,6 @@ function discover_by_url($url, $arr = null) {
// try and discover stuff from the feeed
require_once('library/simplepie/simplepie.inc');
$feed = new SimplePie();
$level = 0;
$x = z_fetch_url($guid, false, $level, array('novalidate' => true));
@@ -1093,6 +1092,12 @@ function discover_by_url($url, $arr = null) {
// Don't try and parse an empty string
$feed->set_raw_data(($xml) ? $xml : '<?xml version="1.0" encoding="utf-8" ?><xml></xml>');
// We can preserve iframes because we will strip them in the purifier after
// checking for supported video sources.
$strip_htmltags = $feed->strip_htmltags;
array_splice($strip_htmltags, array_search('iframe', $strip_htmltags), 1);
$feed->strip_htmltags($strip_htmltags);
$feed->init();
if($feed->error())
logger('scrape_feed: Error parsing XML: ' . $feed->error());
@@ -1627,22 +1632,30 @@ function find_webfinger_location($j,$rhs) {
return '';
}
function match_webfinger_location($s,$h) {
/**
* @brief Match the webfinger location for the different networks.
*
* @param string $s The string to search in
* @param string $h The host
* @return string
*/
function match_webfinger_location($s, $h) {
// GNU-social and the older StatusNet - the $host/user/123 form doesn't work
if(preg_match('|' . $h . '/index.php/user/([0-9]*?)$|',$s))
if(preg_match('|' . $h . '/index.php/user/([0-9]*?)$|', $s))
return $s;
// Redmatrix / hubzilla
if(preg_match('|' . $h . '/channel/|',$s))
if(preg_match('|' . $h . '/channel/|', $s))
return $s;
// Friendica
if(preg_match('|' . $h . '/profile/|',$s))
if(preg_match('|' . $h . '/profile/|', $s))
return $s;
$arr = array('test' => $s, 'host' => $h, 'success' => false);
call_hooks('match_webfinger_location',$arr);
call_hooks('match_webfinger_location', $arr);
if($arr['success'])
return $s;
return '';
}