Commit b6459e61 authored by Klaus Weidenbach's avatar Klaus Weidenbach

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.
parent b4f65840
......@@ -32,7 +32,8 @@
"michelf/php-markdown" : "^1.7",
"pixel418/markdownify": "^2.2",
"bshaffer/oauth2-server-php": "^1.9",
"ezyang/htmlpurifier": "^4.9"
"ezyang/htmlpurifier": "^4.9",
"simplepie/simplepie": ">=1.4.4 || dev-master"
},
"require-dev" : {
"php" : ">=7.0",
......@@ -56,5 +57,9 @@
"minimum-stability" : "stable",
"config" : {
"notify-on-install" : false
}
},
"repositories": [{
"type": "vcs",
"url": "https://github.com/simplepie/simplepie"
}]
}
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "f1d40dcfbbb2f5364ad55235efaeb5ab",
"content-hash": "62261cde663585403a8dd8fda5b85a95",
"packages": [
{
"name": "bshaffer/oauth2-server-php",
......@@ -668,6 +668,69 @@
"xml"
],
"time": "2016-10-09T22:57:52+00:00"
},
{
"name": "simplepie/simplepie",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/simplepie/simplepie.git",
"reference": "59e7204610d3a8989822eba1c0cbf1d1680bd10d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/59e7204610d3a8989822eba1c0cbf1d1680bd10d",
"reference": "59e7204610d3a8989822eba1c0cbf1d1680bd10d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "~4 || ~5"
},
"suggest": {
"mf2/mf2": "Microformat module that allows for parsing HTML for microformats"
},
"type": "library",
"autoload": {
"psr-0": {
"SimplePie": "library"
}
},
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Ryan Parman",
"homepage": "http://ryanparman.com/",
"role": "Creator, alumnus developer"
},
{
"name": "Geoffrey Sneddon",
"homepage": "http://gsnedders.com/",
"role": "Alumnus developer"
},
{
"name": "Ryan McCue",
"email": "me@ryanmccue.info",
"homepage": "http://ryanmccue.info/",
"role": "Developer"
}
],
"description": "A simple Atom/RSS parsing library for PHP",
"homepage": "http://simplepie.org/",
"keywords": [
"atom",
"feeds",
"rss"
],
"support": {
"source": "https://github.com/simplepie/simplepie/tree/master",
"issues": "https://github.com/simplepie/simplepie/issues"
},
"time": "2017-04-06 03:36:48"
}
],
"packages-dev": [
......@@ -3612,6 +3675,7 @@
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"simplepie/simplepie": 20,
"behat/behat": 0,
"behat/mink-extension": 0,
"behat/mink-goutte-driver": 0
......
This diff is collapsed.
......@@ -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 '';
}
......
# SimplePie
## Authors and contributors
* [Ryan Parman](http://ryanparman.com)
* [Geoffrey Sneddon](http://gsnedders.com)
* [Ryan McCue](http://ryanmccue.info)
* [Michael Shipley](http://michaelpshipley.com)
* [Steve Minutillo](http://minutillo.com/steve/)
## License
[New BSD license](http://www.opensource.org/licenses/bsd-license.php)
## Project status
SimplePie is currently maintained by Ryan McCue.
At the moment, there isn't a lot of active development happening. If the community decides that SimplePie is a valuable tool, then the community will come together to maintain it into the future.
If you're interested in getting involved with SimplePie, please get in touch with Ryan McCue.
## What comes in the package?
1. `simplepie.inc` - The SimplePie library. This is all that's required for your pages.
2. `README.markdown` - This document.
3. `LICENSE.txt` - A copy of the BSD license.
4. `compatibility_test/` - The SimplePie compatibility test that checks your server for required settings.
5. `demo/` - A basic feed reader demo that shows off some of SimplePie's more noticable features.
6. `idn/` - A third-party library that SimplePie can optionally use to understand Internationalized Domain Names (IDNs).
7. `test/` - SimplePie's unit test suite.
## To start the demo
1. Upload this package to your webserver.
2. Make sure that the cache folder inside of the demo folder is server-writable.
3. Navigate your browser to the demo folder.
## Need support?
For further setup and install documentation, function references, etc., visit:
[http://simplepie.org/wiki/](http://simplepie.org/wiki/)
For bug reports and feature requests, visit:
[http://github.com/rmccue/simplepie/issues](http://github.com/rmccue/simplepie/issues)
Support mailing list -- powered by users, for users.
[http://tech.groups.yahoo.com/group/simplepie-support/](http://tech.groups.yahoo.com/group/simplepie-support/)
SIMPLEPIE COMPATIBILITY TEST
1) Upload sp_compatibility_test.php to the web-accessible root of your website.
For example, if your website is www.example.com, upload it so that you can get
to it at www.example.com/sp_compatibility_test.php
2) Open your web browser and go to the page you just uploaded.
\ No newline at end of file
<?php
require_once 'simplepie.inc';
function normalize_character_set($charset)
{
return strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset));
}
function build_character_set_list()
{
$file = new SimplePie_File('http://www.iana.org/assignments/character-sets');
if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)))
{
return false;
}
else
{
$data = explode("\n", $file->body);
unset($file);
foreach ($data as $line)
{
// New character set
if (substr($line, 0, 5) === 'Name:')
{
// If we already have one, push it on to the array
if (isset($aliases))
{
for ($i = 0, $count = count($aliases); $i < $count; $i++)
{
$aliases[$i] = normalize_character_set($aliases[$i]);
}
$charsets[$preferred] = array_unique($aliases);
natsort($charsets[$preferred]);
}
$start = 5 + strspn($line, "\x09\x0A\x0B\xC\x0D\x20", 5);
$chars = strcspn($line, "\x09\x0A\x0B\xC\x0D\x20", $start);
$aliases = array(substr($line, $start, $chars));
$preferred = end($aliases);
}
// Another alias
elseif(substr($line, 0, 6) === 'Alias:')
{
$start = 7 + strspn($line, "\x09\x0A\x0B\xC\x0D\x20", 7);
$chars = strcspn($line, "\x09\x0A\x0B\xC\x0D\x20", $start);
$aliases[] = substr($line, $start, $chars);
if (end($aliases) === 'None')
{
array_pop($aliases);
}
elseif (substr($line, 7 + $chars + 1, 21) === '(preferred MIME name)')
{
$preferred = end($aliases);
}
}
}
// Compatibility replacements
$compat = array(
'EUC-KR' => 'windows-949',
'GB2312' => 'GBK',
'GB_2312-80' => 'GBK',
'ISO-8859-1' => 'windows-1252',
'ISO-8859-9' => 'windows-1254',
'ISO-8859-11' => 'windows-874',
'KS_C_5601-1987' => 'windows-949',
'TIS-620' => 'windows-874',
//'US-ASCII' => 'windows-1252',
'x-x-big5' => 'Big5',
);
foreach ($compat as $real => $replace)
{
if (isset($charsets[$real]) && isset($charsets[$replace]))
{
$charsets[$replace] = array_merge($charsets[$replace], $charsets[$real]);
unset($charsets[$real]);
}
elseif (isset($charsets[$real]))
{
$charsets[$replace] = $charsets[$real];
$charsets[$replace][] = normalize_character_set($replace);
unset($charsets[$real]);
}
else
{
$charsets[$replace][] = normalize_character_set($real);
}
$charsets[$replace] = array_unique($charsets[$replace]);
natsort($charsets[$replace]);
}
// Sort it
uksort($charsets, 'strnatcasecmp');
// Check that nothing matches more than one
$all = call_user_func_array('array_merge', $charsets);
$all_count = array_count_values($all);
if (max($all_count) > 1)
{
echo "Duplicated charsets:\n";
foreach ($all_count as $charset => $count)
{
if ($count > 1)
{
echo "$charset\n";
}
}
}
// And we're done!
return $charsets;
}
}
function charset($charset)
{
$normalized_charset = normalize_character_set($charset);
if ($charsets = build_character_set_list())
{
foreach ($charsets as $preferred => $aliases)
{
if (in_array($normalized_charset, $aliases))
{
return $preferred;
}
}
return $charset;
}
else
{
return false;
}
}
function build_function()
{
if ($charsets = build_character_set_list())
{
$return = <<<EOF
function charset(\$charset)
{
// Normalization from UTS #22
switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\\1', \$charset)))
{
EOF;
foreach ($charsets as $preferred => $aliases)
{
foreach ($aliases as $alias)
{
$return .= "\t\tcase " . var_export($alias, true) . ":\n";
}
$return .= "\t\t\treturn " . var_export($preferred, true) . ";\n\n";
}
$return .= <<<EOF
default:
return \$charset;
}
}
EOF;
return $return;
}
else
{
return false;
}
}
if (php_sapi_name() === 'cli' && realpath($_SERVER['argv'][0]) === __FILE__)
{
echo build_function();
}
?>
\ No newline at end of file
This diff is collapsed.
<?php
namespace Zotlabs\Tests\Unit\includes;
use Zotlabs\Tests\Unit\UnitTestCase;
/**
* @brief Unit Test case for include/feedutils.php file.
*/
class FeedutilsTest extends UnitTestCase {
public function test_normalise_id() {
$this->assertEquals('id', normalise_id('id'));
$this->assertEquals('id', normalise_id('X-ZOT:id'));
$this->assertEquals('id id2', normalise_id('X-ZOT:id X-ZOT:id2'));
$this->assertEmpty(normalise_id(''));
}
public function test_encode_rel_links() {
// invalid params return empty array
$this->assertEquals([], encode_rel_links('string'));
$this->assertEquals([], encode_rel_links([]));
$b = ['attribs' => ['' => [
'rel' => 'rel_value',
'type' => 'type_value',
'href' => 'href_value'
]]];
$blink1 = ['link1' => $b];
$bresult[] = $b['attribs'][''];
$this->assertEquals($bresult, encode_rel_links($blink1));
}
/* public function test_encode_rel_links_fail() {
$a = [ 'key' => 'value'];
$this->assertFalse(encode_rel_links($a));
//Illegal string offset 'attribs'
}*/
public function test_atom_author() {
$this->assertEquals('', atom_author('', 'name', 'uri', 72, 72, 'png', 'photourl'));
$a = '<tag>
<name>name</name>
<uri>uri</uri>
<link rel="photo" type="png" media:width="72" media:height="72" href="http://photourl" />
<link rel="avatar" type="png" media:width="72" media:height="72" href="http://photourl" />
</tag>';
$this->assertXmlStringEqualsXmlString($a, atom_author('tag', 'name', 'uri', 72, 72, 'png', 'http://photourl'));
}
}
This diff is collapsed.
......@@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'SimplePie' => array($vendorDir . '/simplepie/simplepie/library'),
'OAuth2' => array($vendorDir . '/bshaffer/oauth2-server-php/src'),
'Michelf' => array($vendorDir . '/michelf/php-markdown'),
'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
......
This diff is collapsed.
......@@ -683,5 +683,70 @@
"keywords": [
"html"
]
},
{
"name": "simplepie/simplepie",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/simplepie/simplepie.git",
"reference": "59e7204610d3a8989822eba1c0cbf1d1680bd10d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/simplepie/simplepie/zipball/59e7204610d3a8989822eba1c0cbf1d1680bd10d",
"reference": "59e7204610d3a8989822eba1c0cbf1d1680bd10d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "~4 || ~5"
},
"suggest": {
"mf2/mf2": "Microformat module that allows for parsing HTML for microformats"
},
"time": "2017-04-06T03:36:48+00:00",
"type": "library",
"installation-source": "source",
"autoload": {
"psr-0": {
"SimplePie": "library"
}
},
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Ryan Parman",
"homepage": "http://ryanparman.com/",
"role": "Creator, alumnus developer"
},
{
"name": "Geoffrey Sneddon",
"homepage": "http://gsnedders.com/",
"role": "Alumnus developer"
},
{
"name": "Ryan McCue",
"email": "me@ryanmccue.info",
"homepage": "http://ryanmccue.info/",
"role": "Developer"
}
],
"description": "A simple Atom/RSS parsing library for PHP",
"homepage": "http://simplepie.org/",
"keywords": [
"atom",
"feeds",
"rss"
],
"support": {
"source": "https://github.com/simplepie/simplepie/tree/master",
"issues": "https://github.com/simplepie/simplepie/issues"
}
}
]
SimplePie
=========
SimplePie is a very fast and easy-to-use class, written in PHP, that puts the
'simple' back into 'really simple syndication'. Flexible enough to suit
beginners and veterans alike, SimplePie is focused on [speed, ease of use,
compatibility and standards compliance][what_is].
[what_is]: http://simplepie.org/wiki/faq/what_is_simplepie
Requirements
------------
* PHP 5.3.0+ (5.3.6+ recommended since SimplePie 1.4.2)
* Support for PHP 5.2 stopped in branch `one-dot-three`
* Support for PHP 4 stopped in branch `one-dot-two`
* libxml2 (certain 2.7.x releases are too buggy for words, and will crash)
* One of iconv, mbstring or intl extensions
* cURL or fsockopen()
* PCRE support
What comes in the package?
--------------------------
1. `library/` - SimplePie classes for use with the autoloader
2. `autoloader.php` - The SimplePie Autoloader if you want to use the separate
file version.
3. `README.markdown` - This document.
4. `LICENSE.txt` - A copy of the BSD license.
5. `compatibility_test/` - The SimplePie compatibility test that checks your
server for required settings.
6. `demo/` - A basic feed reader demo that shows off some of SimplePie's more
noticeable features.
7. `idn/` - A third-party library that SimplePie can optionally use to
understand Internationalized Domain Names (IDNs).
8. `build/` - Scripts related to generating pieces of SimplePie
9. `test/` - SimplePie's unit test suite.
### Where's `simplepie.inc`?
Since SimplePie 1.3, we've split the classes into separate files to make it easier
to maintain and use.
If you'd like a single monolithic file, you can run `php build/compile.php` to
generate `SimplePie.compiled.php`.
To start the demo
-----------------
1. Upload this package to your webserver.
2. Make sure that the cache folder inside of the demo folder is server-writable.
3. Navigate your browser to the demo folder.
Need support?
-------------
For further setup and install documentation, function references, etc., visit
[the wiki][wiki]. If you're using the latest version off GitHub, you can also
check out the [API documentation][].
If you can't find an answer to your question in the documentation, head on over
to one of our [support channels][]. For bug reports and feature requests, visit
the [issue tracker][].
[API documentation]: http://dev.simplepie.org/api/
[wiki]: http://simplepie.org/wiki/
[support channels]: http://simplepie.org/support/
[issue tracker]: http://github.com/simplepie/simplepie/issues
Project status
--------------
SimplePie is currently maintained by Malcolm Blaney.
As an open source project, SimplePie is maintained on a somewhat sporadic basis.
This means that feature requests may not be fulfilled straight away, as time has
to be prioritized.
If you'd like to contribute to SimplePie, the best way to get started is to fork
the project on GitHub and send pull requests for patches. When doing so, please
be aware of our [coding standards][].
[coding standards]: http://simplepie.org/wiki/misc/coding_standards
Authors and contributors
------------------------
### Current
* [Malcolm Blaney][] (Maintainer, support)
### Alumni
* [Ryan McCue][] (developer, support)
* [Ryan Parman][] (Creator, developer, evangelism, support)
* [Geoffrey Sneddon][] (Lead developer)
* [Michael Shipley][] (Submitter of patches, support)
* [Steve Minutillo][] (Submitter of patches)
[Malcolm Blaney]: https://unicyclic.com/mal
[Ryan McCue]: http://ryanmccue.info
[Ryan Parman]: http://ryanparman.com
[Geoffrey Sneddon]: http://gsnedders.com
[Michael Shipley]: http://michaelpshipley.com
[Steve Minutillo]: http://minutillo.com/steve/
### Contributors
For a complete list of contributors:
1. Pull down the latest SimplePie code
2. In the `simplepie` directory, run `git shortlog -ns`
License
-------
[New BSD license](http://www.opensource.org/licenses/BSD-3-Clause)
<?php
/**
* SimplePie
*
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
* Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* * Neither the name of the SimplePie Team nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
* AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
* @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue
* @author Ryan Parman
* @author Geoffrey Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
// autoloader
spl_autoload_register(array(new SimplePie_Autoloader(), 'autoload'));
if (!class_exists('SimplePie'))
{
trigger_error('Autoloader not registered properly', E_USER_ERROR);
}
/**
* Autoloader class
*