Browse Source

Revert "SimplePie : tolérance caractères UTF-8 invalides"

This reverts commit 7e66db7782b7fa7f7262a70ccea5c377341886cd.
Alexandre Alapetite 12 years ago
parent
commit
d51048196b
2 changed files with 6 additions and 1 deletions
  1. 2 1
      lib/SimplePie/SimplePie.php
  2. 4 0
      lib/SimplePie/SimplePie/Parser.php

+ 2 - 1
lib/SimplePie/SimplePie.php

@@ -1382,7 +1382,8 @@ class SimplePie
 		foreach ($encodings as $encoding)
 		{
 			// Change the encoding to UTF-8 (as we always use UTF-8 internally)
-			if ($utf8_data = $this->registry->call('Misc', 'change_encoding', array($this->raw_data, $encoding, 'UTF-8')))
+			if ($utf8_data = (empty($encoding) || $encoding === 'UTF-8') ? $this->raw_data :	//FreshRSS
+				$this->registry->call('Misc', 'change_encoding', array($this->raw_data, $encoding, 'UTF-8')))
 			{
 				// Create new parser
 				$parser = $this->registry->create('Parser');

+ 4 - 0
lib/SimplePie/SimplePie/Parser.php

@@ -145,6 +145,10 @@ class SimplePie_Parser
 				$dom->loadXML($data);
 				$this->encoding = $encoding = $dom->encoding = 'UTF-8';
 				$data2 = $dom->saveXML();
+				if (function_exists('mb_convert_encoding'))
+				{
+					$data2 = mb_convert_encoding($data2, 'UTF-8', 'UTF-8');
+				}
 				if (strlen($data2) > (strlen($data) / 2.0))
 				{
 					$data = $data2;