summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-11-07 15:00:45 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2014-11-07 15:00:45 +0100
commite92d57740718b142b5157e371ce5ddde7f6a9795 (patch)
tree0a997191604dbb1a0699180c87ea2a0f6e04ba06
parent7524609f3fa487941e829e2f10117d2ea08f3200 (diff)
another round of trying to fix the heise.de encoding issues
-rw-r--r--CHANGELOG.md3
-rw-r--r--articleenhancer/xpatharticleenhancer.php15
-rw-r--r--tests/unit/articleenhancer/XPathArticleEnhancerTest.php3
3 files changed, 7 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 56b7c6a26..6190d50bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+owncloud-news (4.0.1)
+* **Bugfix**: Fix heise.de encoding issues
+
owncloud-news (4.0.0)
* **Backwards incompatible change**: Calculate item ids differently which leads to unpreventable readding of read articles
* **Backwards incompatible change**: Get rid of cacheCuration setting
diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php
index c48237367..b283786b8 100644
--- a/articleenhancer/xpatharticleenhancer.php
+++ b/articleenhancer/xpatharticleenhancer.php
@@ -51,13 +51,9 @@ class XPathArticleEnhancer implements ArticleEnhancer {
foreach($this->regexXPathPair as $regex => $search) {
if(preg_match($regex, $item->getUrl())) {
- list($body, $httpEncoding) = $this->getFile($item->getUrl());
- if(preg_match('/(?<=charset=)[^;]*/', $body, $matches)) {
- $encoding = $matches[0];
- $body = Encoding::convert($body, $encoding);
- $body = mb_convert_encoding($body, 'HTML-ENTITIES',
- strtoupper($encoding));
- }
+ $body = $this->getFile($item->getUrl());
+ $body = mb_convert_encoding($body, 'HTML-ENTITIES',
+ mb_detect_encoding($body));
$dom = new DOMDocument();
@@ -95,10 +91,7 @@ class XPathArticleEnhancer implements ArticleEnhancer {
$client = $this->clientFactory->build();
$client->execute($url);
$client->setUserAgent('Mozilla/5.0 AppleWebKit');
- return [
- $client->getContent(),
- $client->getEncoding()
- ];
+ return $client->getContent();
}
diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
index e133f6e16..2d207d177 100644
--- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
+++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
@@ -59,9 +59,6 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
$this->client->expects($this->once())
->method('getContent')
->will($this->returnValue($body));
- $this->client->expects($this->once())
- ->method('getEncoding')
- ->will($this->returnValue($encoding));
}