diff options
author | Bernhard Posselt <Raydiation@users.noreply.github.com> | 2015-03-30 19:40:07 +0200 |
---|---|---|
committer | Bernhard Posselt <Raydiation@users.noreply.github.com> | 2015-03-30 19:40:07 +0200 |
commit | 05985bc2965f8a332e98121050ba1f07343bbc0f (patch) | |
tree | 96ca5d59b7ce3c9d3678dd95d8595145d1d5df08 /articleenhancer | |
parent | eb7fc97f33cadcf041a06915b8f1650a9b4f6bbb (diff) | |
parent | ee3d2332ec97487893ae5f1f46b599c550b25eb6 (diff) |
Merge pull request #751 from owncloud/next
Changes for 8.1
Diffstat (limited to 'articleenhancer')
-rw-r--r-- | articleenhancer/globalarticleenhancer.php | 8 | ||||
-rw-r--r-- | articleenhancer/xpatharticleenhancer.php | 9 |
2 files changed, 10 insertions, 7 deletions
diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php index 004d92a9f..e7f5ca177 100644 --- a/articleenhancer/globalarticleenhancer.php +++ b/articleenhancer/globalarticleenhancer.php @@ -33,7 +33,9 @@ class GlobalArticleEnhancer implements ArticleEnhancer { // inside <p> tags $body = '<div>' . $item->getBody() . '</div>'; - @$dom->loadHTML($body, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); + $isOk = @$dom->loadHTML( + $body, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD + ); $xpath = new DOMXpath($dom); @@ -57,7 +59,9 @@ class GlobalArticleEnhancer implements ArticleEnhancer { } // save all changes back to the item - $item->setBody(trim($dom->saveHTML())); + if ($isOk) { + $item->setBody(trim($dom->saveHTML())); + } return $item; } diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index 67fbf78d2..61bf230a0 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -25,7 +25,6 @@ use OCA\News\Db\Item; class XPathArticleEnhancer implements ArticleEnhancer { - private $maximumTimeout; private $clientFactory; private $regexXPathPair; @@ -72,7 +71,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { } $dom = new DOMDocument(); - @$dom->loadHTML($body); + $isOk = @$dom->loadHTML($body); $xpath = new DOMXpath($dom); $xpathResult = $xpath->evaluate($search); @@ -90,7 +89,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { $xpathResult, $item->getUrl() ); - if($xpathResult) { + if($isOk && $xpathResult !== false && $xpathResult !== '') { $item->setBody($xpathResult); } } @@ -122,7 +121,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { $dom->preserveWhiteSpace = false; if($xmlString === '') { - return false; + return ''; } $xmlString = '<div>' . $xmlString . '</div>'; @@ -130,7 +129,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { LIBXML_HTML_NODEFDTD); if(!$isOk) { - return false; + return ''; } foreach (['href', 'src'] as $attribute) { |