From 65c6b08aed762eda0f7e8fa4de018bd7bac5f37b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Fri, 8 Jul 2016 14:06:00 +0200 Subject: [PATCH] fix DOMNode and DOMElement mess MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/LWNprevBridge.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bridges/LWNprevBridge.php b/bridges/LWNprevBridge.php index f147985c..b0e4f7de 100644 --- a/bridges/LWNprevBridge.php +++ b/bridges/LWNprevBridge.php @@ -52,11 +52,12 @@ class LWNprevBridge extends BridgeAbstract{ $context = stream_context_create($context); } - $html=file_get_contents($uri, false, $context) + $content=file_get_contents($uri, false, $context) or $this->returnServerError('No results for LWNprev'); libxml_use_internal_errors(true); - $html=DOMDocument::loadHTML($html); + $html=new DOMDocument(); + $html->loadHTML($content); libxml_clear_errors(); $cat1=''; @@ -101,7 +102,7 @@ class LWNprevBridge extends BridgeAbstract{ $h2FirstChild=$h2->firstChild; $this->jumpToNextTag($h2FirstChild); - if($h2FirstChild->tagName==='a'){ + if($h2FirstChild->nodeName==='a'){ $item->uri='https://lwn.net'.$h2FirstChild->getAttribute('href'); }else{ $item->uri=$realURI.'#'.$URICounter; @@ -145,8 +146,9 @@ class LWNprevBridge extends BridgeAbstract{ if( !$node || ( $node->nodeType!==XML_TEXT_NODE && ( - $node->tagName==='h2' || - in_array($node->getAttribute('class'),array('Cat1HL','Cat2HL')) + $node->nodeName==='h2' || + (!is_null($node->attributes) && !is_null($class=$node->attributes->getNamedItem('class')) && + in_array($class->nodeValue,array('Cat1HL','Cat2HL'))) ) ) ){