]> granicus.if.org Git - php/commitdiff
Fix bug #71501
authorHieu Le <letrunghieu.cse09@gmail.com>
Wed, 3 Feb 2016 06:20:30 +0000 (13:20 +0700)
committerNikita Popov <nikic@php.net>
Thu, 4 Feb 2016 10:44:56 +0000 (11:44 +0100)
NEWS
ext/xmlrpc/tests/bug71501.phpt [new file with mode: 0644]
ext/xmlrpc/xmlrpc-epi-php.c

diff --git a/NEWS b/NEWS
index e42e479a4a8246d958ef2f58a8284e0f73520a67..7966ce5fc2cee4f16f067a3d91f1055f12d10e09 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,9 @@ PHP                                                                        NEWS
 - Standard:
   . Fixed bug #70720 (strip_tags improper php code parsing). (Julien)
 
+- XMLRPC:
+  . Fixed bug #71501 (xmlrpc_encode_request ignores encoding option). (Hieu Le)
+
 04 Feb 2016 PHP 7.0.3
 
 - Core:
diff --git a/ext/xmlrpc/tests/bug71501.phpt b/ext/xmlrpc/tests/bug71501.phpt
new file mode 100644 (file)
index 0000000..950d21d
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Bug #71501 (xmlrpc_encode_request ignores encoding option)
+--SKIPIF--
+<?php
+if (!extension_loaded("xmlrpc")) print "skip";
+?>
+--FILE--
+<?php
+$params = 'Lê Trung Hiếu';
+echo xmlrpc_encode_request('foo', $params, ['encoding' => 'UTF-8', 'escaping' => 'markup']);
+?>
+--EXPECTF--
+<?xml version="1.0" encoding="UTF-8"?>
+<methodCall>
+<methodName>foo</methodName>
+<params>
+ <param>
+  <value>
+   <string>Lê Trung Hiếu</string>
+  </value>
+ </param>
+</params>
+</methodCall>
index dd39047bf00594e158581972572b7a8f6b6d71c0..ea62bdc9a9000cdf2c527ae419e64cc13ea220a1 100644 (file)
@@ -411,45 +411,46 @@ static void set_output_options(php_output_options* options, zval* output_opts)
                                        }
                                }
 
-                               /* encoding code set */
-                               if ((val = zend_hash_str_find(Z_ARRVAL_P(output_opts), ENCODING_KEY, ENCODING_KEY_LEN)) != NULL) {
-                                       if (Z_TYPE_P(val) == IS_STRING) {
-                                               options->xmlrpc_out.xml_elem_opts.encoding = estrdup(Z_STRVAL_P(val));
-                                       }
+                       }
+
+                       /* encoding code set */
+                       if ((val = zend_hash_str_find(Z_ARRVAL_P(output_opts), ENCODING_KEY, ENCODING_KEY_LEN)) != NULL) {
+                               if (Z_TYPE_P(val) == IS_STRING) {
+                                       options->xmlrpc_out.xml_elem_opts.encoding = estrdup(Z_STRVAL_P(val));
                                }
+                       }
 
-                               /* escaping options */
-                               if ((val = zend_hash_str_find(Z_ARRVAL_P(output_opts), ESCAPING_KEY, ESCAPING_KEY_LEN)) != NULL) {
-                                       /* multiple values allowed.  check if array */
-                                       if (Z_TYPE_P(val) == IS_ARRAY) {
-                                               zval* iter_val;
-
-                                               options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_no_escaping;
-
-                                               ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(val), iter_val) {
-                                                       if (Z_TYPE_P(iter_val) == IS_STRING && Z_STRVAL_P(iter_val)) {
-                                                               if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_CDATA)) {
-                                                                       options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_cdata_escaping;
-                                                               } else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_NON_ASCII)) {
-                                                                       options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_ascii_escaping;
-                                                               } else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_NON_PRINT)) {
-                                                                       options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_print_escaping;
-                                                               } else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_MARKUP)) {
-                                                                       options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_markup_escaping;
-                                                               }
+                       /* escaping options */
+                       if ((val = zend_hash_str_find(Z_ARRVAL_P(output_opts), ESCAPING_KEY, ESCAPING_KEY_LEN)) != NULL) {
+                               /* multiple values allowed.  check if array */
+                               if (Z_TYPE_P(val) == IS_ARRAY) {
+                                       zval* iter_val;
+
+                                       options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_no_escaping;
+
+                                       ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(val), iter_val) {
+                                               if (Z_TYPE_P(iter_val) == IS_STRING && Z_STRVAL_P(iter_val)) {
+                                                       if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_CDATA)) {
+                                                               options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_cdata_escaping;
+                                                       } else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_NON_ASCII)) {
+                                                               options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_ascii_escaping;
+                                                       } else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_NON_PRINT)) {
+                                                               options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_print_escaping;
+                                                       } else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_MARKUP)) {
+                                                               options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_markup_escaping;
                                                        }
-                                               } ZEND_HASH_FOREACH_END();
-                                               /* else, check for single value */
-                                       } else if (Z_TYPE_P(val) == IS_STRING) {
-                                               if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_CDATA)) {
-                                                       options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_cdata_escaping;
-                                               } else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_NON_ASCII)) {
-                                                       options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_ascii_escaping;
-                                               } else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_NON_PRINT)) {
-                                                       options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_print_escaping;
-                                               } else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_MARKUP)) {
-                                                       options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_markup_escaping;
                                                }
+                                       } ZEND_HASH_FOREACH_END();
+                                       /* else, check for single value */
+                               } else if (Z_TYPE_P(val) == IS_STRING) {
+                                       if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_CDATA)) {
+                                               options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_cdata_escaping;
+                                       } else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_NON_ASCII)) {
+                                               options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_ascii_escaping;
+                                       } else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_NON_PRINT)) {
+                                               options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_print_escaping;
+                                       } else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_MARKUP)) {
+                                               options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_markup_escaping;
                                        }
                                }
                        }