use single quotes and clean up comments

This commit is contained in:
Bernhard Posselt 2014-11-23 17:08:19 +01:00
Родитель bbd765b76a
Коммит 692ecc06f5
2 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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 <meta charset="..."> or
// <meta http-equiv="Content-Type" ...> is specified and use that
// <meta http-equiv="Content-Type" ...> 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 = "/<meta\s+[^>]*(?:charset\s*=\s*['\"]([^>'\"]*)['\"]" .
"|http-equiv\s*=\s*['\"]content-type['\"]\s+[^>]*content\s*=\s*['\"][^>]*charset=([^>]*)['\"])[^>]*>/i";
if(preg_match($encregex, $body, $matches)) {
$regex = '/<meta\s+[^>]*(?: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();