diff options
author | Bernhard Posselt <Raydiation@users.noreply.github.com> | 2013-10-20 14:16:55 -0700 |
---|---|---|
committer | Bernhard Posselt <Raydiation@users.noreply.github.com> | 2013-10-20 14:16:55 -0700 |
commit | 2f55613bfeca0d72ab55a1dbf7277b449edf5b77 (patch) | |
tree | 993528e42bdd4ca6855bd0c220eff71d37e7fec9 | |
parent | 9c5b23f68181cff062d1b81a2a815c032989157d (diff) | |
parent | 9666a55c073a231599493251e301d584515bdbb0 (diff) |
Merge pull request #397 from owncloud/xpathenchancer-fallback
If the xpath enchancer fails, fallback to the original body
-rw-r--r-- | articleenhancer/xpatharticleenhancer.php | 4 | ||||
-rw-r--r-- | tests/unit/articleenhancer/XPathArticleEnhancerTest.php | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index 93ceaf896..0a2d6e56c 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -86,7 +86,9 @@ class XPathArticleEnhancer implements ArticleEnhancer { $xpathResult = $this->substituteRelativeLinks($xpathResult, $item->getUrl()); $sanitizedResult = $this->purifier->purify($xpathResult); - $item->setBody($sanitizedResult); + if( $sanitizedResult ) { + $item->setBody($sanitizedResult); + } } } diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php index 26381057c..798fa9203 100644 --- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php +++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php @@ -149,7 +149,7 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { ->will($this->returnValue(null)); $result = $this->testEnhancer->enhance($item); - $this->assertEquals(null, $result->getBody()); + $this->assertEquals('Hello thar', $result->getBody()); } @@ -172,7 +172,7 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { ->will($this->returnValue(null)); $result = $this->testEnhancer->enhance($item); - $this->assertEquals(null, $result->getBody()); + $this->assertEquals('Hello thar', $result->getBody()); } @@ -200,7 +200,7 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { ->will($this->returnValue(null)); $result = $this->testEnhancer->enhance($item); - $this->assertEquals(null, $result->getBody()); + $this->assertEquals('Hello thar', $result->getBody()); } @@ -285,4 +285,4 @@ class XPathArticleEnhancerTest extends \OCA\AppFramework\Utility\TestUtility { $this->assertEquals('<img src="http://www.url.com/absolute/url.png"><a target="_blank" href="mailto:test@testsite.com">mail</a>', $result->getBody()); } -}
\ No newline at end of file +} |