summaryrefslogtreecommitdiffstats
path: root/articleenhancer
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-09-22 13:00:08 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-09-22 13:00:08 +0200
commit7b4281baaa14f2f44cd4bba116a671c80586902a (patch)
tree42572d0dc6a6b955c847fb89be3e06a8be622658 /articleenhancer
parent4c52f52107995745d9d8de03cffc637cd504b224 (diff)
backport to old libxml version
Diffstat (limited to 'articleenhancer')
-rw-r--r--articleenhancer/globalarticleenhancer.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php
index 512d51697..1b6713ef7 100644
--- a/articleenhancer/globalarticleenhancer.php
+++ b/articleenhancer/globalarticleenhancer.php
@@ -24,8 +24,7 @@ class GlobalArticleEnhancer implements ArticleEnhancer {
*/
public function enhance(Item $item) {
$dom = new \DOMDocument();
- @$dom->loadHTML($item->getBody(), LIBXML_HTML_NOIMPLIED |
- LIBXML_HTML_NODEFDTD);
+ @$dom->loadHTML($item->getBody());
$xpath = new \DOMXpath($dom);
// remove youtube autoplay
@@ -46,6 +45,12 @@ class GlobalArticleEnhancer implements ArticleEnhancer {
}
}
+ // remove <!DOCTYPE
+ $dom->removeChild($dom->firstChild);
+
+ // remove <html><body></body></html>
+ $dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild);
+
// save all changes back to the item
$item->setBody(trim($dom->saveHTML()));