#include "php_soap.h"
#include "ext/libxml/php_libxml.h"
+#include "ext/standard/base64.h"
#include <libxml/parserInternals.h>
#include "zend_strtod.h"
if (data && data->children) {
if (data->children->type == XML_TEXT_NODE && data->children->next == NULL) {
whiteSpace_collapse(data->children->content);
- ZVAL_STRING(ret, data->children->content, 1);
+
+ if (type->type_str && !strcmp(type->type_str, "base64Binary")) {
+ unsigned char *str;
+ int str_len;
+
+ str = php_base64_decode(data->children->content, strlen(data->children->content), &str_len);
+ ZVAL_STRINGL(ret, str, str_len, 0);
+ } else {
+ ZVAL_STRING(ret, data->children->content, 1);
+ }
} else if (data->children->type == XML_CDATA_SECTION_NODE && data->children->next == NULL) {
- ZVAL_STRING(ret, data->children->content, 1);
+ if (type->type_str && !strcmp(type->type_str, "base64Binary")) {
+ unsigned char *str;
+ int str_len;
+
+ str = php_base64_decode(data->children->content, strlen(data->children->content), &str_len);
+ ZVAL_STRINGL(ret, str, str_len, 0);
+ } else {
+ ZVAL_STRING(ret, data->children->content, 1);
+ }
} else {
soap_error0(E_ERROR, "Encoding: Violation of encoding rules");
}
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
- str = php_escape_html_entities(Z_STRVAL(tmp), Z_STRLEN(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
+ str = php_escape_html_entities(Z_STRVAL(tmp), Z_STRLEN(tmp), &new_len, 0, 0, NULL TSRMLS_CC);
zval_dtor(&tmp);
}
static xmlNodePtr to_xml_stringl(encodeTypePtr type, zval *data, int style, xmlNodePtr parent)
{
xmlNodePtr ret;
+ zend_bool benc = type->type_str && !strcmp(type->type_str, "base64Binary");
ret = xmlNewNode(NULL,"BOGUS");
xmlAddChild(parent, ret);
FIND_ZVAL_NULL(data, ret, style);
if (Z_TYPE_P(data) == IS_STRING) {
- xmlNodeSetContentLen(ret, Z_STRVAL_P(data), Z_STRLEN_P(data));
+ if (!benc) {
+ xmlNodeSetContentLen(ret, Z_STRVAL_P(data), Z_STRLEN_P(data));
+ } else {
+ char *str;
+ int str_len;
+
+ str = php_base64_encode(Z_STRVAL_P(data), Z_STRLEN_P(data), &str_len);
+ xmlNodeSetContentLen(ret, str, str_len);
+ efree(str);
+ }
} else {
zval tmp = *data;
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
- xmlNodeSetContentLen(ret, Z_STRVAL(tmp), Z_STRLEN(tmp));
+ if (!benc) {
+ xmlNodeSetContentLen(ret, Z_STRVAL(tmp), Z_STRLEN(tmp));
+ } else {
+ char *str;
+ int str_len;
+
+ str = php_base64_encode(Z_STRVAL(tmp), Z_STRLEN(tmp), &str_len);
+ xmlNodeSetContentLen(ret, str, str_len);
+ efree(str);
+ }
zval_dtor(&tmp);
}
--FILE--
<?php
$client = new SoapClient(NULL,array("location"=>"test://","uri"=>"http://soapinterop.org/","trace"=>1,"exceptions"=>0));
-$client->__soapCall("echoBase64", array('TmVicmFza2E='), array("soapaction"=>"http://soapinterop.org/","uri"=>"http://soapinterop.org/"));
+$client->__soapCall("echoBase64", array('Nebraska'), array("soapaction"=>"http://soapinterop.org/","uri"=>"http://soapinterop.org/"));
echo $client->__getlastrequest();
$HTTP_RAW_POST_DATA = $client->__getlastrequest();
include("round2_base.inc");
?>
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
-<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoBase64><param0 xsi:type="xsd:string">TmVicmFza2E=</param0></ns1:echoBase64></SOAP-ENV:Body></SOAP-ENV:Envelope>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoBase64><param0 xsi:type="xsd:string">Nebraska</param0></ns1:echoBase64></SOAP-ENV:Body></SOAP-ENV:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soapinterop.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoBase64Response><outputBase64 xsi:type="xsd:base64Binary">TmVicmFza2E=</outputBase64></ns1:echoBase64Response></SOAP-ENV:Body></SOAP-ENV:Envelope>
ok
--FILE--
<?php
$client = new SoapClient(NULL,array("location"=>"test://","uri"=>"http://soapinterop.org/","trace"=>1,"exceptions"=>0));
-$client->__soapCall("echoBase64", array(new SoapParam(new SoapVar('TmVicmFza2E=',XSD_BASE64BINARY),"inputBase64")), array("soapaction"=>"http://soapinterop.org/","uri"=>"http://soapinterop.org/"));
+$client->__soapCall("echoBase64", array(new SoapParam(new SoapVar('Nebraska',XSD_BASE64BINARY),"inputBase64")), array("soapaction"=>"http://soapinterop.org/","uri"=>"http://soapinterop.org/"));
echo $client->__getlastrequest();
$HTTP_RAW_POST_DATA = $client->__getlastrequest();
include("round2_base.inc");