Git Product home page Git Product logo

simplepie's Introduction

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.

Requirements

  • PHP 7.2+ (Required since SimplePie 1.8.0)
  • libxml2 (certain 2.7.x releases are too buggy for words, and will crash)
  • One of iconv, mbstring or intl extensions
  • Optionally, intl extension, symfony/polyfill-intl-idn or cURL extension built with IDN support to support IDNs
  • cURL or fsockopen()
  • PCRE support

PSR-18: HTTP Client support

Since SimplePie 1.9.0 you can use a PSR-18 HTTP client like Guzzle or every other implementation. Please note that you would also need PSR-17 implementations of RequestFactoryInterface and an UriFactoryInterface implementation.

$simplepie = new \SimplePie\SimplePie();
$simplepie->set_http_client(
    new \GuzzleHttp\Client(),
    new \GuzzleHttp\Psr7\HttpFactory(),
    new \GuzzleHttp\Psr7\HttpFactory(),
);

PSR-16: Caching support

Since SimplePie 1.8.0 you can use the PSR-16 cache from Symfony or every other implementation.

$simplepie = new \SimplePie\SimplePie();
$simplepie->set_cache(
    new \Symfony\Component\Cache\Psr16Cache(
        new \Symfony\Component\Cache\Adapter\FilesystemAdapter()
    ),
);

What comes in the package?

  1. src/ - 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. LICENSES/BSD-3-Clause.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. build/ - Scripts related to generating pieces of SimplePie
  8. 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, see the assets in the releases, or you can run php build/compile.php to generate SimplePie.compiled.php yourself.

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. 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.

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.

The main development for the next minor release happens in master branch. Please create your pull requests primarily against this branch.

We do not actively provide bug fixes or security fixes for older versions. Nevertheless, you are welcome to create backport PRs if you still need support for older PHP versions. Please open your PR against the appropriate branch.

branch requires
master PHP 7.2.0+
one-dot-seven PHP 5.6.0+
one-dot-three PHP 5.2.0+

Authors and contributors

Current

Alumni

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

simplepie's People

Contributors

alkarex avatar art4 avatar blat avatar carusogabriel avatar colonelmoutarde avatar dawnbreak avatar desrosj avatar devlinjunker avatar galvani avatar gsnedders avatar hardeepasrani avatar hubbitus avatar icewind1991 avatar ifsnop avatar janpettermg avatar jrfnl avatar jtojnar avatar lexaurin avatar mattrobenolt avatar mblaney avatar mikeschinkel avatar minutils avatar mkly avatar molayli avatar paolooo avatar presskopp avatar remicollet avatar rmccue avatar skyzyx avatar xm74 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplepie's Issues

SimplePie crashes Apache

If you are using SimplePie on WAMP localhost and if you have PHP version > 5.2.2 then it will crash the Apache. Make sure you download more PHP versions for WAMP, cause SimplePie will work only on 5.2.2 and bellow

Fails Strict Standards - Multiple Errors

On the 1.2.1 release, I turned on strict standards error reporting before using Simple Pie using this:

error_reporting(E_ALL | E_STRICT | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING);

While running, I received perhaps a hundred errors regarding:

  • Assigning the return value of new by reference is deprecated. (In other words, drop the =& new stuff.)
  • Non-static method SimplePie_Misc::[method went here] should not be called statically. (In other words, use $this-> instead.)
  • It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead. (Self explanatory. Follow the error's instructions.)
  • is_a(): Deprecated. Please use the instanceof operator. (Self explanatory. Follow the error's instructions.)

can't override sort_items in multifeed + merge_items can't be overridden

Originally reported by Michael Shipley as issue 50

The SP function "merge_items" located at line 3010 in SP111 sorts items by calling the function "sort_items" statically, preventing "sort_items" from being overridden for a custom sort by extending the SP class.

To fix this, you need to replace "SimplePie" with "&$this" on line 3039 in SP111:

3039 usort($items, array('SimplePie', 'sort_items'));

should be:
3039 usort($items, array(&$this, 'sort_items'));

Also in the "get_items" function on line 2909 in SP111 the function "merge_items" is also called statically so its not possible to override that either by extending the SP class. It must be modified in the same way to allow it to be overridden.

2913 return SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);

should be:
2913 return $this->merge_items($this->multifeed_objects, $start, $end, $this->item_limit);

SimplePie::get_favicon() should cache atom:icon

Originally reported by Geoffrey Sneddon as issue 23

Currently we only cache /favicon.ico, but we don't cache atom:icon when we use that. Need to move around code within the function to avoid duplicating all the caching code there when adding this.

Allow the XML parser to be more lax

Originally reported by Anonymous as issue 92

Some feeds contain white space at the beginning of the feed, and on PHP 4.4.9 on Debian etch, this is correctly flagged as malformed XML. Likewise, the parser chokes in the presence of otherwise harmless control characters - quite correctly, given the XML specs.

PHP 5 on MacOS X 10.5 parses these feeds, skipping over the offending characters.

This code (a subclass of SimplePie_Parser) fixes it, even it has to steal some code from the superclass to get past the BOMs:

class CleanerParser extends SimplePie_Parser {

function parse(&$data, $encoding) {
}

// Remove illegal control chars - leave only 0x09, 0x0A, 0x0D    

    $txt = ereg_replace("[\x01-\x08]|\x0B|\x0C|[\x0E-\x1F]", "", $txt); 
}

// Strip BOM:

// UTF-32 Big Endian BOM

if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
{

    $data = substr($data, 4);

}

// UTF-32 Little Endian BOM

elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
{

    $data = substr($data, 4);

}

// UTF-16 Big Endian BOM

elseif (substr($data, 0, 2) === "\xFE\xFF")
{

    $data = substr($data, 2);

}

// UTF-16 Little Endian BOM

elseif (substr($data, 0, 2) === "\xFF\xFE")
{

    $data = substr($data, 2);

}

// UTF-8 BOM

elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
{

    $data = substr($data, 3);

}

// Remove white space (empty lines, etc.) before the first XML decl.

$data = trim($data);

return SimplePie_Parser::parse($data, $encoding);

Use strict-comparison where possible

Originally reported by Geoffrey Sneddon as issue 21

Work started on this in r944, but that only touched == and != leaving implicit comparison untouched (e.g., if ($var). This probably means searching through simplepie.inc for all if, for, and while statements. Not fun.

However lacking in excitement this is, it needs to be done — bugs have already slipped through because of this.

Simplepie fetches same data for all the three urls with latest code. Works fine with old code.

Not able to fetch data where urls are not unique. Here URL is same and only a parameter is passed to get different XMLs.
"http://indiatoday.intoday.in/site/rssGenerator.jsp?secId=4&feed=LATEST%20NEWS",
"http://indiatoday.intoday.in/site/rssGenerator.jsp?secId=30&feed=COVER%20STORY"
"http://indiatoday.intoday.in/site/rssGenerator.jsp?feed=Latest%20Issue"
Simplepie fetches same data for all the three urls.
This is not working with latest code rmccue-SimplePie-9a1ebc0. It is working with old code rmccue-SimplePie-cb3b25c.

Cannot parse any of the NASA feeds

Originally reported by Anonymous as issue 148

SimplePie v1.2 has difficulties with the RSS feeds available at:
http://www.nasa.gov/rss/index.html

With the vast majority of them SimplePie is not able to parse any items from the feeds. The function $feed->get_item_quantity() returns 0. For examples, see:
http://www.nasa.gov/rss/breaking_news.rss
http://www.nasa.gov/rss/lroupdate_archive.xml
http://www.nasa.gov/rss/shuttle_updates.xml
http://www.nasa.gov/rss/image_of_the_day.rss

There are a few feeds on that page that SimplePie can process.

Break methods like init() and sanitize() into smaller sub-methods

Originally reported by Ryan Parman as issue 52

This has not yet been properly evaluated, so nothing stated here is a definitive "we need to do this", but it would likely be helpful for people extending SimplePie to be able to override smaller chunks of large methods (such as init() and sanitize()) without having to re-write the entire thing.

An example of this is for those who want to add custom favicon sniffing code. At the moment it is very difficult to add functionality like this without overriding the entire sanitize() method. If this were broken into smaller sub-methods, such a task would likely be easier.

Invalid UTF-8 bytes returned

Originally reported by Anonymous as issue 145

Certain invalid byte sequences are given as output even if UTF-8 is explicitly set e.g.:

0xe28022
0xa0
0xa3
0x88

Examples of these can be found by downloading these feeds with SimplePie:

http://feeds.feedburner.com/BronteCapital?format=xml
http://www.thisismoney.co.uk/xml/page-rss.xml?in_page_id=53946
http://cynicuseconomicus.blogspot.com/feeds/posts/default

When you then attempt to insert these into a Postgres database, an error is given due to the malformed UTF-8:

Warning: pg_query(): Query failed: ERROR: invalid byte sequence for encoding "UTF8": 0xe28022
HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

Cache status methods

Originally reported by Ryan Parman as issue 37

We've gotten many requests over the years from people who want to know more about the status of their cache. I threw together an add-on for SP 1.0 that broke for 1.1. I'd like to propose adding a few methods for 1.2.

  • $feed->get_cache() would return some sort of reference to the cache object.
  • $feed->get_cache()->get_exists() would be a boolean response. True if cache exists for this feed (DB or FS)
  • $feed->get_cache()->is_fresh() would be a boolean response. True if cache exists for this feed. Should we allow values for "Yes, it's fresh", "No, it's expired", and that in-between "It's expired but the most recent fetch failed so we're re-using the expired cache"?
  • $feed->get_cache()->get_filename() would return either the FS filename or a DB identifer (or whatever the most useful data is for this).
  • $feed->get_cache()->get_timestamp() would return the Unix timestamp for when the cache was created/refreshed (i.e. whenever the cache decides is the "start").
  • $feed->get_cache()->get_time_remaining() would return the number of seconds until the cache expires.

I'm open to other ideas, as well as best ways to implement this or even if users would find it useful.

get_favicon() should try to get favicons that are located in non-standard locations (favicon autodiscovery)

Originally reported by Michael Lehmkuhl as issue 27

Sometimes sites define their favicon location using a

tag instead of placing it at http://domain.com/favicon.ico. This might be done especially on larger sites that use a CDN or networks of sites that all share the same favicon file.

The attached patch is how I added this functionality for a recent project. I'd love to see it rolled into SimplePie proper in some way, shape or form.

Twitter's downtime page breaks SimpiePie's cache

When Twitter goes down, the host is still reachable because they send the user to a page explaining that Twitter is over capacity. SimpiePie attempts to continue caching and therefore it breaks and shows nothing or an error.

Use PHP 5.3's new DateTime::createFromFormat method to parse date

Originally reported by Anonymous as issue 141

PHP 5.3 included a new, interesting method in the DateTime class: createFromFormat
Basically, it does the exact opposite of date(): given a string and a format, it returns the timestamp.
I believe this method is much faster than the actual SimplePie_Parse_Date class, and could be use instead of it if the server is running 5.3+.

Quotes are removed from ETag headers

Originally reported by Anonymous as issue 113

A header sent from teh servert like this:

ETag: "aae714dc9ba620a634334090ec80271e"

will get the quotes removed by SimplePie_HTTP_Parser. Those quotes are required according to http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11

However, some servers do not include them, and just adding them to the request If-None-Match header will confuse the server at the next request, and it will likely produce a 200 answer instead of a 304, even if there are no changes.

Examples of feeds that require the tag to be sent back exactly as it is received in order to obtain a correct 304 response:

http://feeds.feedburner.com/JewelryBlogFromJewelrymallcom (incorrectly sending the ETag without quotes)

http://jbrana.blogspot.com/feeds/posts/default (here, SimplePie incorrectly removes quotes)

Send Accept header

Originally reported by Geoffrey Sneddon as issue 89

The following should do for fetching feeds (images, for example, are different).

Accept: application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1

Only Final Content-Type Should Be Used

Originally reported by Geoffrey Sneddon as issue 1

For compatibility with the real web, we need to only take the final Content-Type header, and not concatenate them (which is technically the correct behaviour according to RFC2616, it's just totally useless in the real world).

SimplePie::sort_items() should sort NULL values to the end of the array instead of the beginning.

Originally reported by Ryan Parman as issue 34

SimplePie::sort_items() uses PHP's basic usort() function, and that if one of the comparative values is null (which, I believe, is what get_date('U') returns with a non-existent or invalid date stamp), usort() will simply not sort the value, leaving it at the beginning of the returned array. This tends to cause quite a bit of confusion for users, so we should add additional logic that checks the value of get_date() before comparison, and if it is null (or similar), move that item to the end of the array.

Get items by date range

Originally reported by Geoffrey Sneddon as issue 28

We should be able to get items in a date range. This should, for the sake of consistency, take two parameters which are both the number of seconds since the epoch (i.e., $start, $end; or maybe $start, $duration).

media:content tag not handled correctly

Currently standalone media:content tags are only parsed if the url attrib isset. A condition should be added which checks if there is a media:player if the url is not set as specified by http://video.search.yahoo.com/mrss "url should specify the direct url to the media object. If not included, a media:player element must be specified".

I ran into this problem parsing http://www.slideshare.net/rss/user/plaxoderek1.

In 1.3 branch conditional statement is on line 4808 and in 1.2 on 5058. Change also requires putting assignment of $url variable within an if statement.

Replace Misc::get_element() with DOMDocument for autodiscovery

Originally reported by Philippe L. as issue 143

I've tried the following PHP script to run on 2 different environments. And to my surprise, I obtain different results depending on the environment it's run from.

$feed = new SimplePie();

$feed->set_feed_url('http://www.lemonde.fr');
$feed->enable_cache(false);

$feed->init();

if($feed->data) echo 'SimplePie: parsing successful';
else echo $feed->error;

The environments are as follow:

Environment 1 (PHP4): SimplePie 1.2 / PHP4.4.9 / libxml2 2.6.27 / mbstring / No iconv / PCRE 7.7 2008-05-07 / libcurl/7.15.5 OpenSSL/0.9.8c zlib/1.2.3 libidn/0.6.5
Environment 2 (PHP5): SimplePie 1.2 / PHP5.2.9 / libxml2 2.7.3 / mbstring 4.4.4 / iconv 2.5 / PCRE 7.8 2008-09-05 / libcurl/7.19.4 OpenSSL/0.9.8i zlib/1.2.3 libidn/0.6.5
When run on Environment 1 (PHP4), the script is able to find the feed and renders:

SimplePie: parsing successful

But, if I execute the exact same PHP script on Environment 2 (PHP5), it renders this simplepie error:

A feed could not be found at http://www.lemonde.fr

I have also tried other experiments:
If I force_feed(), I get the following SimplePie error on both environments:

XML error: syntax error at line 3, column 45

If I replace the feed URL by the actual feed location http://www.lemonde.fr/rss/une.xml, the feed is correctly parsed by SimplePie on both environments.

Make it easier to add to, remove from, replace, or disable element and attribute stripping.

Originally reported by Ryan Parman as issue 41

Currently, SimplePie::strip_htmltags() and SimplePie::strip_attributes() contain a default set of elements/attributes (referred to simply as "elements" from here forward) to strip. To replace the list, you simply pass in a new array of elements, and to disable you pass in a boolean false.

But there are also times when people want to take the existing default list, and either add new elements to it, or remove elements from it. There are samples of code posted to http://simplepie.org/wiki/reference/simplepie/strip_htmltags but this could definitely be made easier by integrating support into SimplePie::strip_htmltags() and SimplePie::strip_attributes() themselves.

We could add a second parameter to these methods where a value of zero (default) equates to "replace" (i.e. passing in a new array or a boolean false replaces existing settings). A value of 1 (or any other positive integer) would be equivalent to "add to", and a value of -1 (or any other negative integer) would be equivalent to "remove from".

In the end, people who want to keep the default list of HTML elements to strip but want to remove object, param, and embed from the strip-list could do this:

$feed->set_htmltags(array('object', 'param', 'embed'), -1);

Alternatively, we could go with keywords like "add", "replace" (default), and "remove". Thoughts?

strip_htmltags() does not work fully/correctly on news.google.com feed

Originally reported by Kory Roberts as issue 131

For testing purposes, I've reduced my code to this:

include_once('simplepie.inc');
$feed = new

SimplePie('news.google.com/news?pz=1&ned=us&hl=en&q=video&output=rss');
//$feed->strip_htmltags(array('object', 'param', 'embed'));
foreach($feed->get_items() as $item) {
print $item->get_content();
}

I've queried for the search term "video" so embedded videos are more likely to come up in the feed.

I thought "object", "param", and "embed" tags were supposed to be stripped by default, but even with that line of code uncommented, not all 3 tags are stripped. The behavior is curious...

$feed->strip_htmltags(array('object', 'param', 'embed'));

...seems to strip "object" and "param", but NOT "embed".

$feed->strip_htmltags(array('embed'));

...seems to strip NONE of the default tags, not even "embed".

The "font" tag seems to be occurring in the feed, too...so the stripping seems to be failing (likely) on all tags.

make xml_dump available as a string

Originally reported by Julian Bond as issue 72

In order to make my caching and fetching scheme more efficient, I had a need to know whether a feed had changed. So what I was doing was taking an MD5 hash of the sanitised output storing it and comparing it. Two things would make this easier. The fetching scheme is to back off collection if the feed is changing much and fetch more frequently if it keeps changing.

  1. Providing xml_dump as a string that can be queried rather than echoing it out as a web page. Somewhere around line 1778 set a public variable $this->clean_source = $data;
  2. Expose something in the cacheing scheme to tell the program if the feed has changed.

Problems with "?feed=rss2" adresses

Look here http://rss.lfsaction.net/feeds_checker.php
The 3rd feed "http://noriyaro.com/?feed=rss2" won't output any news... I don't
know why, but I have done some testing and only feeds in this format do it
(?feed=...) and if I put it on the end of list it works, but I need more of them
and if I put 2 of this kind on the end of a list, the one before last still
won't work :/. By the way I use

$rss_feeds = file("rss_list.txt");

foreach($rss_feeds as $rss_feed) {

$feed = new SimplePie();
$feed->set_feed_url($rss_feed);

Thanks for any help :/. I think there's a bug somewhere.

SimplePie_Sanitize::sanitize does not strip attributes correctly.

Originally reported by Anonymous as issue 142

While parsing an RSS feed, sanitize failed to strip class and style attributes correctly. I stripped the offending CDATA to this:

<description><![CDATA[
<img src="" class="" style=""/>
]]>

        </description>

Playing around, I removed the "/" at the end of the img tag and suddenly it worked! So, I went to the sanitize method and tweaked the regex used to clean up attributes (somewhere around line 14874). Essentially, I changed the very tail end of it from

'>/'

to

'\/?>/'

to allow for a closing slash. That seems to have fixed it.

Using Build 20090627192103

Re-write our HTTP support from scratch

Originally reported by Ryan Parman as issue 10

Re-write our HTTP support from scratch, which will allow for things like SSL support, HTTP Proxies, HTTP 401: Digest Authentication, obey any cache expiry set in the HTTP headers, HTTP status codes, ability to see if a remote file exists without actually downloading it, etc.

Debug Mode

Originally reported by Ryan Parman as issue 53

We've talked about this before, but there should be some sort of debug mode that — when enabled — can give us useful information for debugging issues.
This debug info might include:

* PHP version
* SimplePie/Plugin version
* Versions of installed extensions
* Database type and version
* Error stack trace
* Expected cache location and whether it exists and is writable (file system caching only)
* Other stuff?

Latitude and longitude are not parsed if excess whitespace exists in the element data

Originally reported by Ryan McCue as issue 138

If there is leading or trailing whitespace inside the georss:point element, the latitude and longitude are parsed incorrectly.

Google Maps does this in their feeds, e.g. http://maps.google.co.uk/maps/ms?ie=UTF8&hl=en&vps=1&jsv=165c&msa=0&output=georss&msid=114629588063241738205.00046e30584a54b324d5b

There are two solutions to this: either remove the ^ and $ boundaries in the regular expressions to match this, or run trim() on the data before matching.

Thoughts?

Bug when checking ->error() with multiple feeds

Originally reported by Matt Dunn as issue 128

Below is the code:

$parser->set_feed_url($file);
$parser->init();
$parser->handle_content_type();
if($parser->error()) {
    # Write to log what happened
    echo 'error ('.$file.')';
}
else {
    # Parse feed
    echo 'valid ('.$file.')';
}

So it is pretty straight forward. I loop over a directory of XML files
and if there is an error then I log the error, otherwise I parse the
file.

I did a quick test and I put in 10 valid feeds. I got all "valid". To
make sure I had everything working I made one invalid (added an & to it).

I then ran the test again and the file with the & in it came back as an
"error". This was great except that the remaining 4 files left to parse
all came back with the same error.

I removed the & and ran again, and all 10 worked.

So I am assuming that when you do init() that it is not infact actually
clearing out any previous errors and so even if the next feed is valid,
calling error() will still return true.

Anyone else come across this?

change_encoding function has wrong case in string comparison

On line ~9450, it compares $input === 'Windows-1252' && $output == 'UTF-8'. However, the relevant windows format is always returned as 'windows-1252' in lower case, so this comparison fails when it should succeed, and in fact the document fails to be parsed in my case because it can't find an encoding. The comparison should be changed to:

$input === 'windows-1252' &&...

This made it work fine in my case.

Reverse date order

Originally reported by Julian Bond as issue 73

It's quite handy when storing items in a database to store them in reverse order to the way they appear in the feed. eg LIFO. This is because most feeds contain items in Date descending and the order_by_date control seems to force this. So the last item in the feed is actually the first one to be checked and updated or inserted.

The feature request is for a new variable and set function, reverse_order which does a ``$items = array_reverse($items);` somewhere around line 3035 in the trunk code.

Array element test needed

Originally reported by Doug Kaye as issue 137

Notice: Undefined index: content in /var/www/haystack/packages/simplepie_1.1.2/simplepie.inc on line 4380

Fix: wrap foreach() with if (array_key_exists('content',$group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]))

Warning: error_log() has been disabled for security reasons

Originally reported by Anonymous as issue 136

Many hosts disable error_log() in various and sundry ways. In WP we do something like this to avoid triggering warnings and errors. Even this is sometimes not sufficient to avoid problems with some hosts, but accommodates most.

            $log_error = true;
            if ( ! function_exists('error_log') )
                    $log_error = false;

            $log_file = @ini_get('error_log');
            if ( !empty($log_file) && ('syslog' != $log_file) && !@is_writable($log_file) )
                    $log_error = false;

            if ( $log_error )
                    @error_log($error_str, 0);

See http://core.trac.wordpress.org/ticket/10291

PHP Deprecated warning when passing return value of new operator as reference

Originally reported by Richard Miller as issue 150

Upgrading to PHP 5.3 caused the PHP Deprecated warning "Assigning the return value of new by reference is deprecated" in the various lines where a new object is created with the =& operator. This occurs 100+ times. Is a fix like this in the roadmap for SimplePie 1.2 or only for version 2 since it's specifically for PHP 5?

Best,
Richard

XML error: EntityRef: expecting ';' on valid feed

Originally reported by David Dib as issue 112

I'm experiencing some strange reactions from SimplePie when trying to parse a, from what I can tell, a valid feed. Here is the feed address: http://www.latzucac.com/index.php?x=rss

SimplePie spits out: PHP Notice: XML error: EntityRef: expecting ';' at line 12, column 84 in /var/www/vhosts/vfxy.com/subdomains/photos/httpdocs/robot/SimplePie/simplepie.inc on line 1788

According to FeedValidator.org however it notes that it is a proper feed other than the channel tag issue.

Support Content-Encoding: chunked

Originally reported by Iain Williamson as issue 36

When using Pie with force_fsockopen(true) certain feeds, which are parsed correctly if cURL is used, fail to parse and generate an XML Empty Document Line1 Column 1 notice.

Example of feed that fails with fsockopen : http://www.aldi.co.uk/wineblog/?feed=rss2

Basic debugging show the following:

SimplePie->init() returns false, because
if ($parser->parse($utf8_data, 'UTF-8')) returns false.

In SimplePie_Parser->parse(), its failing on the statement
if (!xml_parse($xml, $data, true))

The xml_error_code is set to 4 which is the constant
XML_ERROR_INVALID_TOKEN.

COMPATIBILITY TEST:

PHP¹ 5.2.0
XML Enabled
PCRE² Enabled
cURL Enabled
Zlib Enabled
mbstring Enabled
iconv Enabled

Platform:

Windows XP

SIMPLEPIE_VERSION 1.1
SIMPLEPIE_BUILD 20080102221556

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.