0001-bugfix-014055.patch (1.5 kb) added by Thomas Koch
Description: testcase and fix
From 006aa1c6caf8dda22f6c5d9809eb46f98c018cb9 Mon Sep 17 00:00:00 2001
From: Thomas Koch <thomas.koch@ymc.ch>
Date: Wed, 3 Dec 2008 16:43:37 +0100
Subject: [PATCH] bugfix #014055
---
src/feed.php | 5 +++++
tests/feed_test.php | 12 ++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/feed.php b/src/feed.php
index c128e02..5571e73 100644
--- a/src/feed.php
+++ b/src/feed.php
@@ -899,6 +899,11 @@ class ezcFeed
*/
public static function parseContent( $content )
{
+ if( empty( $content ) )
+ {
+ throw new ezcFeedParseErrorException( null, "Empty content given." );
+ }
+
$xml = new DOMDocument();
$oldSetting = libxml_use_internal_errors( true );
$retval = $xml->loadXML( $content );
diff --git a/tests/feed_test.php b/tests/feed_test.php
index 24e71d3..0acd510 100644
--- a/tests/feed_test.php
+++ b/tests/feed_test.php
@@ -78,6 +78,18 @@ class ezcFeedTest extends ezcFeedTestCase
$feed = ezcFeed::parse( 'http://ez.no/rss/feed/communitynews' );
}
+ public function testParseEmptyStringThrowsExceptionButNoWarning()
+ {
+ try{
+ ezcFeed::parseContent( '' );
+ }
+ catch( ezcFeedParseErrorException $e )
+ {
+ return;
+ }
+ $this->fail('Expected ezcFeedParseErrorException');
+ }
+
public function testParseBroken()
{
$dot = DIRECTORY_SEPARATOR;
--
1.5.6.5