From 692ecc06f5f69fd0f0eaefde8ef1ab136cfcc70f Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sun, 23 Nov 2014 17:08:19 +0100 Subject: use single quotes and clean up comments --- CHANGELOG.md | 1 + articleenhancer/xpatharticleenhancer.php | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c7cca57c..f40a8081a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ owncloud-news (4.2.0) * **Enhancement**: Add admin setting to set a custom explore service URL * **Enhancement**: Add explore button and show explore button on startup * **Enhancement**: Show a hint when no articles are available +* **Enhancement**: Add spiegel.de enhancer * **Bugfix**: Fix compact view in firefox 34 * **Bugfix**: Show spinner when autopaging * **Bugfix**: Remove race condition when fetching articles that sometimes shows read articles if the user clicks show on only unread and the article request finishes first before the settings request is finished diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index dec0fe760..871752856 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -53,19 +53,19 @@ class XPathArticleEnhancer implements ArticleEnhancer { if(preg_match($regex, $item->getUrl())) { $body = $this->getFile($item->getUrl()); - // Determine document encoding. // First check if either or - // is specified and use that + // is specified and use it // If this fails use mb_detect_encoding() - // Use UTF-8 if mb_detect_encoding does not return anything (or the HTML page is messed up) - $encregex = "/]*(?:charset\s*=\s*['\"]([^>'\"]*)['\"]" . - "|http-equiv\s*=\s*['\"]content-type['\"]\s+[^>]*content\s*=\s*['\"][^>]*charset=([^>]*)['\"])[^>]*>/i"; - if(preg_match($encregex, $body, $matches)) { + $regex = '/]*(?:charset\s*=\s*[\'"]([^>\'"]*)[\'"]' . + '|http-equiv\s*=\s*[\'"]content-type[\'"]\s+[^>]*' . + 'content\s*=\s*[\'"][^>]*charset=([^>]*)[\'"])[^>]*>' . + '/i'; + if(preg_match($regex, $body, $matches)) { $enc = strtoupper($matches[sizeof($matches) - 1]); } else { $enc = mb_detect_encoding($body); } - $enc = $enc ? $enc : "UTF-8"; + $enc = $enc ? $enc : 'UTF-8'; $body = mb_convert_encoding($body, 'HTML-ENTITIES', $enc); $dom = new DOMDocument(); -- cgit v1.2.3