]> granicus.if.org Git - php/commitdiff
Fixed bug #53493 (xmlrpc_decode should not be sensitive to leading whitespace)
authorKalle Sommer Nielsen <kalle@php.net>
Mon, 13 Dec 2010 09:52:05 +0000 (09:52 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Mon, 13 Dec 2010 09:52:05 +0000 (09:52 +0000)
NEWS
ext/xmlrpc/tests/bug53493.phpt [new file with mode: 0644]
ext/xmlrpc/xmlrpc-epi-php.c

diff --git a/NEWS b/NEWS
index 25b2702bf3ef8fd91adbe6031b84a32bc0b0a906..d911872eabb77f079b0958a43f1ac36c0d5699fc 100644 (file)
--- a/NEWS
+++ b/NEWS
 - Streams:
   . Implemented FR #26158 (open arbitrary file descriptor with fopen). (Gustavo)
 
+- XMLRPC-EPI:
+  . Fixed bug #53493 (xmlrpc_decode should not be sensitive to leading 
+    whitespace). (Kalle)
+
 09 Dec 2010, PHP 5.3.4
 - Upgraded bundled Sqlite3 to version 3.7.3. (Ilia)
 - Upgraded bundled PCRE to version 8.10. (Ilia)
diff --git a/ext/xmlrpc/tests/bug53493.phpt b/ext/xmlrpc/tests/bug53493.phpt
new file mode 100644 (file)
index 0000000..2930924
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--\r
+Bug #53493 (xmlrpc_decode should not be sensitive to leading whitespace)\r
+--FILE--\r
+<?php\r
+$req =                 PHP_EOL . \r
+               '<?xml version="1.0"?><methodResponse><params><param>' . \r
+               '<value><string>Hello World</string></value></param>' . \r
+               '</params></methodResponse>';\r
+\r
+var_dump(xmlrpc_decode($req));\r
+echo "Done\n";\r
+?>\r
+--EXPECT--\r
+string(11) "Hello World"\r
+Done\r
index 823b8eb3a2f68ef081119fb361e95d419dd390ae..8c0ec6c86fbd35b8bdb433c1ae9f8b9848300c7e 100644 (file)
@@ -67,6 +67,7 @@
 
 #include "php.h"
 #include "ext/standard/info.h"
+#include "ext/standard/php_string.h"
 #include "ext/date/php_date.h"
 #include "php_ini.h"
 #include "php_xmlrpc.h"
@@ -844,7 +845,10 @@ PHP_FUNCTION(xmlrpc_decode)
        }
 
        if (return_value_used) {
-               zval* retval = decode_request_worker(arg1, arg1_len, arg2_len ? arg2 : NULL, NULL);
+               zval* retval;
+               char *trimmed = php_trim(arg1, arg1_len, NULL, 0, NULL, 1 TSRMLS_CC);
+
+               retval = decode_request_worker(trimmed, strlen(trimmed), arg2_len ? arg2 : NULL, NULL);
                if (retval) {
                        *return_value = *retval;
                        FREE_ZVAL(retval);