Browse Source

Un morceau de tolérance XML oublié

Alexandre Alapetite 12 years ago
parent
commit
316778ef47
1 changed files with 9 additions and 3 deletions
  1. 9 3
      lib/SimplePie/SimplePie.php

+ 9 - 3
lib/SimplePie/SimplePie.php

@@ -1311,8 +1311,10 @@ class SimplePie
 				{
 					$encodings[] = strtoupper($charset[1]);
 				}
-				$encodings = array_merge($encodings, $this->registry->call('Misc', 'xml_encoding', array($this->raw_data, &$this->registry)));
-				$encodings[] = 'UTF-8';
+				else
+				{
+					$encodings[] = '';	//Let the DOM parser decide first
+				}
 			}
 			elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml')
 			{
@@ -1320,6 +1322,10 @@ class SimplePie
 				{
 					$encodings[] = $charset[1];
 				}
+				else
+				{
+					$encodings[] = '';
+				}
 				$encodings[] = 'US-ASCII';
 			}
 			// Text MIME-type default
@@ -1341,7 +1347,7 @@ 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 : $this->registry->call('Misc', 'change_encoding', array($this->raw_data, $encoding, 'UTF-8')))
 			{
 				// Create new parser
 				$parser = $this->registry->create('Parser');