Skip to content

Commit ace71b4

Browse files
letrunghieunikic
authored andcommitted
Fix bug #71501
1 parent cdf99ff commit ace71b4

File tree

3 files changed

+62
-35
lines changed

3 files changed

+62
-35
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ PHP NEWS
2525
- Standard:
2626
. Fixed bug #70720 (strip_tags improper php code parsing). (Julien)
2727

28+
- XMLRPC:
29+
. Fixed bug #71501 (xmlrpc_encode_request ignores encoding option). (Hieu Le)
30+
2831
04 Feb 2016 PHP 7.0.3
2932

3033
- Core:

ext/xmlrpc/tests/bug71501.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #71501 (xmlrpc_encode_request ignores encoding option)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("xmlrpc")) print "skip";
6+
?>
7+
--FILE--
8+
<?php
9+
$params = 'Lê Trung Hiếu';
10+
echo xmlrpc_encode_request('foo', $params, ['encoding' => 'UTF-8', 'escaping' => 'markup']);
11+
?>
12+
--EXPECTF--
13+
<?xml version="1.0" encoding="UTF-8"?>
14+
<methodCall>
15+
<methodName>foo</methodName>
16+
<params>
17+
<param>
18+
<value>
19+
<string>Lê Trung Hiếu</string>
20+
</value>
21+
</param>
22+
</params>
23+
</methodCall>

ext/xmlrpc/xmlrpc-epi-php.c

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -411,45 +411,46 @@ static void set_output_options(php_output_options* options, zval* output_opts)
411411
}
412412
}
413413

414-
/* encoding code set */
415-
if ((val = zend_hash_str_find(Z_ARRVAL_P(output_opts), ENCODING_KEY, ENCODING_KEY_LEN)) != NULL) {
416-
if (Z_TYPE_P(val) == IS_STRING) {
417-
options->xmlrpc_out.xml_elem_opts.encoding = estrdup(Z_STRVAL_P(val));
418-
}
414+
}
415+
416+
/* encoding code set */
417+
if ((val = zend_hash_str_find(Z_ARRVAL_P(output_opts), ENCODING_KEY, ENCODING_KEY_LEN)) != NULL) {
418+
if (Z_TYPE_P(val) == IS_STRING) {
419+
options->xmlrpc_out.xml_elem_opts.encoding = estrdup(Z_STRVAL_P(val));
419420
}
421+
}
420422

421-
/* escaping options */
422-
if ((val = zend_hash_str_find(Z_ARRVAL_P(output_opts), ESCAPING_KEY, ESCAPING_KEY_LEN)) != NULL) {
423-
/* multiple values allowed. check if array */
424-
if (Z_TYPE_P(val) == IS_ARRAY) {
425-
zval* iter_val;
426-
427-
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_no_escaping;
428-
429-
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(val), iter_val) {
430-
if (Z_TYPE_P(iter_val) == IS_STRING && Z_STRVAL_P(iter_val)) {
431-
if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_CDATA)) {
432-
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_cdata_escaping;
433-
} else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_NON_ASCII)) {
434-
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_ascii_escaping;
435-
} else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_NON_PRINT)) {
436-
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_print_escaping;
437-
} else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_MARKUP)) {
438-
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_markup_escaping;
439-
}
423+
/* escaping options */
424+
if ((val = zend_hash_str_find(Z_ARRVAL_P(output_opts), ESCAPING_KEY, ESCAPING_KEY_LEN)) != NULL) {
425+
/* multiple values allowed. check if array */
426+
if (Z_TYPE_P(val) == IS_ARRAY) {
427+
zval* iter_val;
428+
429+
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_no_escaping;
430+
431+
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(val), iter_val) {
432+
if (Z_TYPE_P(iter_val) == IS_STRING && Z_STRVAL_P(iter_val)) {
433+
if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_CDATA)) {
434+
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_cdata_escaping;
435+
} else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_NON_ASCII)) {
436+
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_ascii_escaping;
437+
} else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_NON_PRINT)) {
438+
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_non_print_escaping;
439+
} else if (!strcmp(Z_STRVAL_P(iter_val), ESCAPING_VALUE_MARKUP)) {
440+
options->xmlrpc_out.xml_elem_opts.escaping |= xml_elem_markup_escaping;
440441
}
441-
} ZEND_HASH_FOREACH_END();
442-
/* else, check for single value */
443-
} else if (Z_TYPE_P(val) == IS_STRING) {
444-
if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_CDATA)) {
445-
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_cdata_escaping;
446-
} else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_NON_ASCII)) {
447-
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_ascii_escaping;
448-
} else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_NON_PRINT)) {
449-
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_print_escaping;
450-
} else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_MARKUP)) {
451-
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_markup_escaping;
452442
}
443+
} ZEND_HASH_FOREACH_END();
444+
/* else, check for single value */
445+
} else if (Z_TYPE_P(val) == IS_STRING) {
446+
if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_CDATA)) {
447+
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_cdata_escaping;
448+
} else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_NON_ASCII)) {
449+
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_ascii_escaping;
450+
} else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_NON_PRINT)) {
451+
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_non_print_escaping;
452+
} else if (!strcmp(Z_STRVAL_P(val), ESCAPING_VALUE_MARKUP)) {
453+
options->xmlrpc_out.xml_elem_opts.escaping = xml_elem_markup_escaping;
453454
}
454455
}
455456
}

0 commit comments

Comments
 (0)