Bug #55448 [Com]: Error at a Soap request
| From: | benbunk at gmail dot com | Date: | Wed, 30 Nov 2011 20:53:26 +0000 |
| Subject: | Bug #55448 [Com]: Error at a Soap request | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165596@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55448&edit=1
ID: 55448
Comment by: benbunk at gmail dot com
Reported by: sunfundev at gmail dot com
Summary: Error at a Soap request
Status: Open
Type: Bug
Package: SOAP related
Operating System: Windows/FreeBSD
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
My suggested work-around does not work.
Previous Comments:
------------------------------------------------------------------------
[2011-11-22 18:23:09] benbunk at gmail dot com
PHP 5.2.10 on RHEL 5 (Versions irrelevant)
Description:
Ideally, a xml_encode or xmlspecialchars function would be created to handle this.
There is a set list of acceptable chars in the xml documentation. All other characters not in this
list should be excluded. Here is a short list (more found at the documentation link provided):
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode
character, excluding the surrogate blocks, FFFE, and FFFF. */
Documentation:
--------------
W3C. Extensible Markup Language (XML) 1.0 (Fifth Edition). W3C XML Working Group. 2008.
(http://www.w3.org/TR/xml/#charsets)
Work around:
------------
Here's a simple function in php that can strip out the control characters which is a
good-enough solution but far from complete:
function xmlspecialchars($escapStr) {
$needles = array(
chr(0x0),
chr(0x01),
chr(0x02),
chr(0x03),
chr(0x04),
chr(0x05),
chr(0x06),
chr(0x07),
chr(0x08),
chr(0x09),
chr(0x1),
chr(0x10),
chr(0x11),
chr(0x12),
chr(0x13),
chr(0x14),
chr(0x15),
chr(0x16),
chr(0x17),
chr(0x18),
chr(0x19),
chr(0x2),
chr(0x3),
chr(0x9),
chr(0xa),
chr(0xb),
chr(0xc),
chr(0xd),
chr(0xe),
chr(0xf),
);
return str_replace($needles, ' ', $escapStr);
}
------------------------------------------------------------------------
[2011-08-18 14:22:21] sunfundev at gmail dot com
Change title
------------------------------------------------------------------------
[2011-08-18 14:10:56] sunfundev at gmail dot com
Description:
------------
PHP 5.3.6 on Windows and FreeBSD
There is a problem with soap-call when one of the parameters contains control
characters.
Expected result:
----------------
$options = array(
"location" => Config::$config['soap_location'],
"uri" => Config::$config['soap_uri'],
"trace" => 1,
"exceptions" => true
);
$soap_client = new SoapClient(null, $options);
$result =
$soap_client->login(array('user_name'=>Config::$config['login'],'password'=Config::$config['password']));
$session_id = $result->id;
$entrie = array(
array('name' => 'first_name', 'value' => 'normal
string'),
array('name' => 'last_name', 'value' => (string)chr(0x1A)),
array('name' => 'email1', 'value' =>
'soaptest@soaptest.com')
);
$soap_client->__soapCall("set_entries", array($session_id, 'Leads',
array($entrie)));
Actual result:
--------------
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] error in msg parsing:
XML error parsing SOAP payload on line 2: Invalid character in H:\xampp\htdocs\test.php:55
Stack trace:
#0 H:\xampp\htdocs\test.php(55): SoapClient->__soapCall('set_entries', Array)
#1 {main}
thrown in H:\xampp\htdocs\test.php on line 55
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55448&edit=1