From d4f19a20c64aa9abcf396a252f5057139770ac1e Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 29 Sep 2014 14:08:27 +0200 Subject: require libxml --- articleenhancer/globalarticleenhancer.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'articleenhancer') diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php index 1b6713ef7..7411d0adc 100644 --- a/articleenhancer/globalarticleenhancer.php +++ b/articleenhancer/globalarticleenhancer.php @@ -24,7 +24,12 @@ class GlobalArticleEnhancer implements ArticleEnhancer { */ public function enhance(Item $item) { $dom = new \DOMDocument(); - @$dom->loadHTML($item->getBody()); + + // wrap it inside a div if there is none to prevent invalid wrapping + // inside

tags + $body = '

' . $item->getBody() . '
'; + + @$dom->loadHTML($body, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new \DOMXpath($dom); // remove youtube autoplay @@ -45,12 +50,6 @@ class GlobalArticleEnhancer implements ArticleEnhancer { } } - // remove removeChild($dom->firstChild); - - // remove - $dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild); - // save all changes back to the item $item->setBody(trim($dom->saveHTML())); -- cgit v1.2.3