diff options
-rw-r--r-- | articleenhancer/globalarticleenhancer.php | 2 | ||||
-rw-r--r-- | articleenhancer/xpatharticleenhancer.php | 4 | ||||
-rw-r--r-- | tests/unit/articleenhancer/XPathArticleEnhancerTest.php | 12 | ||||
-rw-r--r-- | utility/faviconfetcher.php | 2 |
4 files changed, 12 insertions, 8 deletions
diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php index 14f92182d..117c0981c 100644 --- a/articleenhancer/globalarticleenhancer.php +++ b/articleenhancer/globalarticleenhancer.php @@ -32,7 +32,7 @@ class GlobalArticleEnhancer implements ArticleEnhancer { // inside <p> tags $body = '<div>' . $item->getBody() . '</div>'; - $dom = Security::scan($body, $dom, function ($xml, $dom) { + Security::scan($body, $dom, function ($xml, $dom) { return @$dom->loadHTML($xml, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET); }); diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index 87c80762b..3edaad695 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -71,7 +71,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { $dom = new \DOMDocument(); $loadEntities = libxml_disable_entity_loader(true); - @$dom->loadHTML($body, LIBXML_NONET); + @$dom->loadHTML($body); libxml_disable_entity_loader($loadEntities); $xpath = new \DOMXpath($dom); @@ -137,7 +137,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { // return, if xml is empty or loading the HTML fails $loadEntities = libxml_disable_entity_loader(true); - if( trim($xmlString) == "" || !@$dom->loadHTML($xmlString, LIBXML_NONET) ) { + if( trim($xmlString) == "" || !@$dom->loadHTML($xmlString) ) { libxml_disable_entity_loader($loadEntities); return $xmlString; } diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php index bc6b737ae..7756c168a 100644 --- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php @@ -60,7 +60,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div', '/explosm.net\/all/' => '//body/*', '/themerepublic.net/' => '//*[@class=\'post hentry\']' - ], + ], $this->config ); $this->redirects = 5; @@ -120,7 +120,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { '/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div', '/explosm.net\/all/' => '//body/*', '/themerepublic.net/' => '//*[@class=\'post hentry\']' - ], + ], $this->config ); @@ -160,7 +160,7 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($item, $this->testEnhancer->enhance($item)); } - + public function testDoesModifiyArticlesThatMatch() { $file = new \stdClass; $file->headers = ["content-type"=>"text/html; charset=utf-8"]; @@ -370,7 +370,11 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase { ->will($this->returnValue($file)); $result = $this->testEnhancer->enhance($item); - $this->assertEquals('<img src="http://www.url.com/absolute/url.png"><a target="_blank" href="mailto:test@testsite.com">mail</a>', $result->getBody()); + $this->assertEquals( + '<img src="http://www.url.com/absolute/url.png">' . + '<a target="_blank" href="mailto:test@testsite.com">mail</a>', + $result->getBody() + ); } } diff --git a/utility/faviconfetcher.php b/utility/faviconfetcher.php index e05a76319..cadc90210 100644 --- a/utility/faviconfetcher.php +++ b/utility/faviconfetcher.php @@ -80,7 +80,7 @@ class FaviconFetcher { if($file->body !== '') { $dom = new \DOMDocument(); - $dom = Security::scan($file->body, $dom, function ($xml, $dom) { + Security::scan($file->body, $dom, function ($xml, $dom) { return @$dom->loadHTML($xml, LIBXML_NONET); }); |