Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #5936 from god107/zf4267
Browse files Browse the repository at this point in the history
Fix for issue #4267
  • Loading branch information
weierophinney committed Mar 10, 2014
2 parents fbf3eef + dc7afd4 commit 69e1333
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/Zend/Feed/Reader/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ public static function importRemoteFeed($uri, Http\ClientInterface $client)
*/
public static function importString($string)
{
$trimmed = trim($string);
if (!is_string($string) || empty($trimmed)) {
throw new Exception\InvalidArgumentException('Only non empty strings are allowed as input');
}

$libxmlErrflag = libxml_use_internal_errors(true);
$oldValue = libxml_disable_entity_loader(true);
$dom = new DOMDocument;
Expand Down
7 changes: 7 additions & 0 deletions tests/ZendTest/Feed/Reader/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@ public function testImportRemoteFeedMethodPerformsAsExpected()
$this->assertEquals(Reader\Reader::TYPE_RSS_20, $type);
}

public function testImportStringMethodThrowProperExceptionOnEmptyString()
{
$this->setExpectedException('Zend\Feed\Reader\Exception\InvalidArgumentException');
$string = ' ';
$feed = Reader\Reader::importString($string);
}

protected function _getTempDirectory()
{
$tmpdir = array();
Expand Down

0 comments on commit 69e1333

Please sign in to comment.