Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.2

Bug #16301 Invalid XML response from server will crash PHP
Submitted: 2009-06-07 12:48 UTC Modified: 2010-02-22 07:14 UTC
From: soryu2 Assigned: doconnor
Status: Closed Package: XML_RPC2 (version 1.0.5)
PHP Version: 5.2.9 OS: Mac OX X.5.7
Roadmaps: (Not assigned)    
Subscription  



Patch Client.php Revisions
Revision 2009-06-08 05:01 UTC
Developer doconnor
 
Download patch

? patch.diff.txt
Index: XML/RPC2/Client.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Client.php,v
retrieving revision 1.15
diff -u -r1.15 Client.php
--- XML/RPC2/Client.php	10 Sep 2008 19:08:53 -0000	1.15
+++ XML/RPC2/Client.php	8 Jun 2009 04:02:19 -0000
@@ -246,7 +246,7 @@
    
     // }}}
     // {{{ displayDebugInformations___()
-	
+    
     /**
      * Display debug informations
      *
@@ -269,7 +269,7 @@
     
     // }}}
     // {{{ displayDebugInformations2___()
-	
+    
     /**
      * Display debug informations (part 2)
      *
Index: XML/RPC2/Backend/Php/Client.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Backend/Php/Client.php,v
retrieving revision 1.10
diff -u -r1.10 Client.php
--- XML/RPC2/Backend/Php/Client.php	30 Jul 2007 08:47:11 -0000	1.10
+++ XML/RPC2/Backend/Php/Client.php	8 Jun 2009 04:02:19 -0000
@@ -91,6 +91,9 @@
      *
      * @param   string      Method name
      * @param   array       Parameters
+     *
+     * @throws XML_RPC2_Exception
+     * @throws Exception On failed XML parsing from response
      */
     public function remoteCall___($methodName, $parameters)
     {
@@ -111,7 +114,8 @@
             $this->displayDebugInformations___($request, $body);
         }
         try {
-            $result = XML_RPC2_Backend_Php_Response::decode(simplexml_load_string($body));
+            $document = new SimpleXMLElement($body);
+            $result   = XML_RPC2_Backend_Php_Response::decode($document);
         } catch (XML_RPC2_Exception $e) {
             if ($this->debug) {
                 if (get_class($e)=='XML_RPC2_FaultException') {
Index: XML/RPC2/Backend/Php/Server.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Backend/Php/Server.php,v
retrieving revision 1.13
diff -u -r1.13 Server.php
--- XML/RPC2/Backend/Php/Server.php	10 Sep 2008 19:03:55 -0000	1.13
+++ XML/RPC2/Backend/Php/Server.php	8 Jun 2009 04:02:20 -0000
@@ -125,7 +125,7 @@
                     return (XML_RPC2_Backend_Php_Response::encodeFault(-32601, 'server error. requested method not found'));
                 }
                 if (!($method->matchesSignature($methodName, $arguments))) {
-                    return (XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters'));		
+                    return (XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters'));        
                 }
             }
             restore_error_handler();
Index: XML/RPC2/Backend/Php/Value.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Backend/Php/Value.php,v
retrieving revision 1.7
diff -u -r1.7 Value.php
--- XML/RPC2/Backend/Php/Value.php	5 Dec 2007 16:35:08 -0000	1.7
+++ XML/RPC2/Backend/Php/Value.php	8 Jun 2009 04:02:20 -0000
@@ -155,8 +155,8 @@
                         // the type 'base64' or 'datetime' is given by xmlrpc_type public property 
                         $explicitType = $nativeValue->xmlrpc_type;
                     } else {
-	                    $nativeValue = serialize($nativeValue);
-	                    $explicitType = 'base64';
+                        $nativeValue = serialize($nativeValue);
+                        $explicitType = 'base64';
                     }
                     break;
                 case 'resource':
Index: XML/RPC2/Backend/Php/Value/Datetime.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Backend/Php/Value/Datetime.php,v
retrieving revision 1.5
diff -u -r1.5 Datetime.php
--- XML/RPC2/Backend/Php/Value/Datetime.php	22 Jan 2006 01:57:00 -0000	1.5
+++ XML/RPC2/Backend/Php/Value/Datetime.php	8 Jun 2009 04:02:20 -0000
@@ -85,13 +85,13 @@
             $scalar = $nativeValue->scalar;
             $timestamp = $nativeValue->timestamp;  
         } else {
-	        if ((is_int($nativeValue)) or (is_float($nativeValue))) {
-	            $scalar = XML_RPC2_Backend_Php_Value_Datetime::_timestampToIso8601($nativeValue);
-	            $timestamp = (int) $nativeValue;
-	        } elseif (is_string($nativeValue)) {
-	            $scalar= $nativeValue;
-	            $timestamp = (int) XML_RPC2_Backend_Php_Value_Datetime::_iso8601ToTimestamp($nativeValue);
-	        } else {
+            if ((is_int($nativeValue)) or (is_float($nativeValue))) {
+                $scalar = XML_RPC2_Backend_Php_Value_Datetime::_timestampToIso8601($nativeValue);
+                $timestamp = (int) $nativeValue;
+            } elseif (is_string($nativeValue)) {
+                $scalar= $nativeValue;
+                $timestamp = (int) XML_RPC2_Backend_Php_Value_Datetime::_iso8601ToTimestamp($nativeValue);
+            } else {
                 throw new XML_RPC2_InvalidTypeException(sprintf('Cannot create XML_RPC2_Backend_Php_Value_Datetime from type \'%s\'.', gettype($nativeValue)));
             }
         }
Index: XML/RPC2/Backend/Xmlrpcext/Client.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Backend/Xmlrpcext/Client.php,v
retrieving revision 1.17
diff -u -r1.17 Client.php
--- XML/RPC2/Backend/Xmlrpcext/Client.php	10 Sep 2008 19:08:53 -0000	1.17
+++ XML/RPC2/Backend/Xmlrpcext/Client.php	8 Jun 2009 04:02:20 -0000
@@ -90,9 +90,9 @@
     {
         $tmp = xmlrpc_encode_request($this->prefix . $methodName, $parameters, array('escaping' => $this->escaping, 'encoding' => $this->encoding));
         if ($this->uglyStructHack) {
-	        // ugly hack because of http://bugs.php.net/bug.php?id=21949
-	        // see XML_RPC2_Backend_Xmlrpcext_Value::createFromNative() from more infos
-	        $request = preg_replace('~<name>xml_rpc2_ugly_struct_hack_(.*)</name>~', '<name>\1</name>', $tmp);
+            // ugly hack because of http://bugs.php.net/bug.php?id=21949
+            // see XML_RPC2_Backend_Xmlrpcext_Value::createFromNative() from more infos
+            $request = preg_replace('~<name>xml_rpc2_ugly_struct_hack_(.*)</name>~', '<name>\1</name>', $tmp);
         } else {
             $request = $tmp;
         }
@@ -105,7 +105,7 @@
         $httpRequest = new XML_RPC2_Util_HTTPRequest($uri, $options);
         $httpRequest->setPostData($request);
         $httpRequest->sendRequest();
-		$body = $httpRequest->getBody();
+        $body = $httpRequest->getBody();
         if ($this->debug) {
             $this->displayDebugInformations___($request, $body);
         }
Index: XML/RPC2/Backend/Xmlrpcext/Server.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Backend/Xmlrpcext/Server.php,v
retrieving revision 1.11
diff -u -r1.11 Server.php
--- XML/RPC2/Backend/Xmlrpcext/Server.php	10 Sep 2008 19:03:55 -0000	1.11
+++ XML/RPC2/Backend/Xmlrpcext/Server.php	8 Jun 2009 04:02:20 -0000
@@ -154,7 +154,7 @@
                     return (XML_RPC2_Backend_Php_Response::encodeFault(-32601, 'server error. requested method not found'));
                 }
                 if (!($method->matchesSignature($methodName, $parameters))) {
-                    return (XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters'));		
+                    return (XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters'));        
                 }
             }
             set_error_handler(array('XML_RPC2_Backend_Xmlrpcext_Server', 'errorToException'));
Index: XML/RPC2/Backend/Xmlrpcext/Value.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Backend/Xmlrpcext/Value.php,v
retrieving revision 1.5
diff -u -r1.5 Value.php
--- XML/RPC2/Backend/Xmlrpcext/Value.php	22 Jan 2006 01:54:00 -0000	1.5
+++ XML/RPC2/Backend/Xmlrpcext/Value.php	8 Jun 2009 04:02:20 -0000
@@ -88,7 +88,7 @@
             $value2 = (string) $value;
             if (!xmlrpc_set_type($value2, $type)) {
                 throw new XML_RPC2_Exception('Error returned from xmlrpc_set_type');
-	        }
+            }
             return $value2;
         }
         return $value;
Index: XML/RPC2/Server/CallHandler.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Server/CallHandler.php,v
retrieving revision 1.6
diff -u -r1.6 CallHandler.php
--- XML/RPC2/Server/CallHandler.php	22 Jan 2006 01:54:48 -0000	1.6
+++ XML/RPC2/Server/CallHandler.php	8 Jun 2009 04:02:20 -0000
@@ -119,7 +119,7 @@
         if (isset($this->methods[$name])) {
             return $this->methods[$name];
         }
-        return false;	
+        return false;    
     }
        
     // }}}
Index: XML/RPC2/Server/Method.php
===================================================================
RCS file: /repository/pear/XML_RPC2/XML/RPC2/Server/Method.php,v
retrieving revision 1.12
diff -u -r1.12 Method.php
--- XML/RPC2/Server/Method.php	2 Dec 2006 18:09:49 -0000	1.12
+++ XML/RPC2/Server/Method.php	8 Jun 2009 04:02:20 -0000
@@ -378,11 +378,11 @@
             'datetime.iso8601' => 'mixed',
             'iso8601' => 'mixed',
             'base64' => 'string'
-        );	
+        );    
         if (isset($convertArray[$tmp])) {
-            return $convertArray[$tmp];	
+            return $convertArray[$tmp];    
         }
-        return 'mixed';	
+        return 'mixed';    
     }
     
 }