use charset preferred by client if possible
authorgggeek <giunta.gaetano@gmail.com>
Wed, 18 Jan 2023 07:55:15 +0000 (07:55 +0000)
committergggeek <giunta.gaetano@gmail.com>
Wed, 18 Jan 2023 07:55:15 +0000 (07:55 +0000)
src/Server.php

index 51b6f01..c23661c 100644 (file)
@@ -547,15 +547,14 @@ class Server
                 arsort($clientAcceptedCharsets);
                 $clientAcceptedCharsets = array_keys($clientAcceptedCharsets);
 
-                // Give preference to internal encoding
-                $knownCharsets = array(PhpXmlRpc::$xmlrpc_internalencoding, 'UTF-8', 'ISO-8859-1', 'US-ASCII');
+                $knownCharsets = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
                 // if mbstring is enabled, we can support other charsets too!
                 /// @todo add a method to the Charset helper to retrieve this list (and remove from it junk entries)
                 if (function_exists('mb_list_encodings')) {
                     $knownCharsets = array_unique(array_merge($knownCharsets, mb_list_encodings()));
                 }
-                foreach ($knownCharsets as $charset) {
-                    foreach ($clientAcceptedCharsets as $accepted) {
+                foreach ($clientAcceptedCharsets as $accepted) {
+                    foreach ($knownCharsets as $charset) {
                         if ($accepted == strtoupper($charset)) {
                             $respEncoding = $charset;
                             break 2;