Переглянути джерело

Bugs chargement des articles complets

Corrige https://github.com/marienfressinaud/FreshRSS/issues/365
Ajoute le nettoyage correct du HTML par SimplePie, ainsi que le décodage
des caractères HTML dans l'URL, et enfin un message dans le syslog pour
chaque article téléchargé
Alexandre Alapetite 12 роки тому
батько
коміт
6f117abfb6
2 змінених файлів з 4 додано та 12 видалено
  1. 1 1
      app/Models/Entry.php
  2. 3 11
      lib/lib_rss.php

+ 1 - 1
app/Models/Entry.php

@@ -159,7 +159,7 @@ class FreshRSS_Entry extends Minz_Model {
 				try {
 				try {
 					// l'article n'est pas en BDD, on va le chercher sur le site
 					// l'article n'est pas en BDD, on va le chercher sur le site
 					$this->content = get_content_by_parsing(
 					$this->content = get_content_by_parsing(
-						$this->link(), $pathEntries
+						htmlspecialchars_decode($this->link(), ENT_QUOTES), $pathEntries
 					);
 					);
 				} catch (Exception $e) {
 				} catch (Exception $e) {
 					// rien à faire, on garde l'ancien contenu (requête a échoué)
 					// rien à faire, on garde l'ancien contenu (requête a échoué)

+ 3 - 11
lib/lib_rss.php

@@ -110,6 +110,7 @@ function sanitizeHTML($data) {
 	static $simplePie = null;
 	static $simplePie = null;
 	if ($simplePie == null) {
 	if ($simplePie == null) {
 		$simplePie = new SimplePie();
 		$simplePie = new SimplePie();
+		$simplePie->init();
 	}
 	}
 	return html_only_entity_decode($simplePie->sanitize->sanitize($data, SIMPLEPIE_CONSTRUCT_MAYBE_HTML));
 	return html_only_entity_decode($simplePie->sanitize->sanitize($data, SIMPLEPIE_CONSTRUCT_MAYBE_HTML));
 }
 }
@@ -118,22 +119,13 @@ function sanitizeHTML($data) {
 function get_content_by_parsing ($url, $path) {
 function get_content_by_parsing ($url, $path) {
 	require_once (LIB_PATH . '/lib_phpQuery.php');
 	require_once (LIB_PATH . '/lib_phpQuery.php');
 
 
+	syslog(LOG_INFO, 'FreshRSS GET ' . $url);
 	$html = file_get_contents ($url);
 	$html = file_get_contents ($url);
 
 
 	if ($html) {
 	if ($html) {
 		$doc = phpQuery::newDocument ($html);
 		$doc = phpQuery::newDocument ($html);
 		$content = $doc->find ($path);
 		$content = $doc->find ($path);
-		$content->find ('*')->removeAttr ('style')
-		                    ->removeAttr ('id')
-		                    ->removeAttr ('class')
-		                    ->removeAttr ('onload')
-		                    ->removeAttr ('target');
-		$content->removeAttr ('style')
-		        ->removeAttr ('id')
-		        ->removeAttr ('class')
-		        ->removeAttr ('onload')
-		        ->removeAttr ('target');
-		return $content->__toString ();
+		return sanitizeHTML($content->__toString());
 	} else {
 	} else {
 		throw new Exception ();
 		throw new Exception ();
 	}
 	}