dmitry Tue Jul 18 15:05:07 2006 UTC Modified files: /php-src/ext/soap php_encoding.c soap.c Log: Unicode support (not finished)
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_encoding.c?r1=1.136&r2=1.137&diff_format=u Index: php-src/ext/soap/php_encoding.c diff -u php-src/ext/soap/php_encoding.c:1.136 php-src/ext/soap/php_encoding.c:1.137 --- php-src/ext/soap/php_encoding.c:1.136 Tue Jul 18 09:24:54 2006 +++ php-src/ext/soap/php_encoding.c Tue Jul 18 15:05:07 2006 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_encoding.c,v 1.136 2006/07/18 09:24:54 dmitry Exp $ */ +/* $Id: php_encoding.c,v 1.137 2006/07/18 15:05:07 dmitry Exp $ */ #include <time.h> @@ -283,17 +283,36 @@ zval **ztype, **zdata, **zns, **zstype, **zname, **znamens; encodePtr enc = NULL; HashTable *ht = Z_OBJPROP_P(data); + char *stype_str = NULL, *ns_str = NULL; + int free_stype = 0, free_ns = 0; if (zend_hash_find(ht, "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) { soap_error0(E_ERROR, "Encoding: SoapVar hasn't 'enc_type' propery"); } + if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) { + if (Z_TYPE_PP(zstype) == IS_STRING) { + stype_str = Z_STRVAL_PP(zstype); + } else if (Z_TYPE_PP(zstype) == IS_UNICODE) { + stype_str = soap_unicode_to_string(Z_USTRVAL_PP(zstype), Z_USTRLEN_PP(zstype) TSRMLS_CC); + free_stype = 1; + } + if (stype_str && zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) { + if (Z_TYPE_PP(zns) == IS_STRING) { + ns_str = Z_STRVAL_PP(zns); + } else if (Z_TYPE_PP(zns) == IS_UNICODE) { + ns_str = soap_unicode_to_string(Z_USTRVAL_PP(zns), Z_USTRLEN_PP(zns) TSRMLS_CC); + free_ns = 1; + } + } + } + if (SOAP_GLOBAL(sdl)) { - if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) { - if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) { - enc = get_encoder(SOAP_GLOBAL(sdl), Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype)); + if (stype_str) { + if (ns_str) { + enc = get_encoder(SOAP_GLOBAL(sdl), ns_str, stype_str); } else { - enc = get_encoder_ex(SOAP_GLOBAL(sdl), Z_STRVAL_PP(zstype), Z_STRLEN_PP(zstype)); + enc = get_encoder_ex(SOAP_GLOBAL(sdl), stype_str, strlen(stype_str)); } } } @@ -311,21 +330,39 @@ } if (style == SOAP_ENCODED || (SOAP_GLOBAL(sdl) && encode != enc)) { - if (zend_hash_find(ht, "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) { - if (zend_hash_find(ht, "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) { - set_ns_and_type_ex(node, Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype)); - } else { - set_ns_and_type_ex(node, NULL, Z_STRVAL_PP(zstype)); - } + if (stype_str) { + set_ns_and_type_ex(node, ns_str, stype_str); } } + if (free_stype) { + efree(stype_str); + } + if (free_ns) { + efree(ns_str); + } + if (zend_hash_find(ht, "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS) { - xmlNodeSetName(node, BAD_CAST(Z_STRVAL_PP(zname))); + if (Z_TYPE_PP(zname) == IS_STRING) { + xmlNodeSetName(node, BAD_CAST(Z_STRVAL_PP(zname))); + } else if (Z_TYPE_PP(zname) == IS_UNICODE) { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(zname), Z_USTRLEN_PP(zname) TSRMLS_CC); + + xmlNodeSetName(node, BAD_CAST(str)); + efree(str); + } } if (zend_hash_find(ht, "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS) { - xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_PP(znamens)); - xmlSetNs(node, nsp); + if (Z_TYPE_PP(znamens) == IS_STRING) { + xmlNsPtr nsp = encode_add_ns(node, Z_STRVAL_PP(znamens)); + xmlSetNs(node, nsp); + } if (Z_TYPE_PP(znamens) == IS_UNICODE) { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(znamens), Z_USTRLEN_PP(znamens) TSRMLS_CC); + + xmlNsPtr nsp = encode_add_ns(node, str); + efree(str); + xmlSetNs(node, nsp); + } } } else { if (SOAP_GLOBAL(class_map) && data && @@ -2624,6 +2661,7 @@ zval* soapvar; char *ns, *cptype; xmlNsPtr nsptr; + zval *tmp; MAKE_STD_ZVAL(soapvar); object_init_ex(soapvar, soap_var_class_entry); @@ -2633,10 +2671,20 @@ #endif add_property_zval(soapvar, "enc_value", ret); parse_namespace(type_name, &cptype, &ns); - nsptr = xmlSearchNs(data->doc, data, BAD_CAST(ns)); - add_property_string(soapvar, "enc_stype", cptype, 1); + nsptr = xmlSearchNs(data->doc, data, BAD_CAST(ns)); + MAKE_STD_ZVAL(tmp); + ZVAL_STRING(tmp, cptype, 1); +#ifdef ZEND_ENGINE_2 + tmp->refcount--; +#endif + add_property_zval(soapvar, "enc_stype", tmp); if (nsptr) { - add_property_string(soapvar, "enc_ns", (char*)nsptr->href, 1); + MAKE_STD_ZVAL(tmp); + ZVAL_STRING(tmp, (char*)nsptr->href, 1); +#ifdef ZEND_ENGINE_2 + tmp->refcount--; +#endif + add_property_zval(soapvar, "enc_ns", tmp); } efree(cptype); if (ns) {efree(ns);} @@ -3199,7 +3247,7 @@ HashTable *ht; int i, count, cur_type, prev_type, different; zval **tmp; - char *prev_stype = NULL, *cur_stype = NULL, *prev_ns = NULL, *cur_ns = NULL; + zval *prev_stype = NULL, *cur_stype = NULL, *prev_ns = NULL, *cur_ns = NULL; if (!array || Z_TYPE_P(array) != IS_ARRAY) { smart_str_appendl(type, "xsd:anyType", sizeof("xsd:anyType")-1); @@ -3224,14 +3272,16 @@ } cur_type = Z_LVAL_PP(ztype); - if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS) { - cur_stype = Z_STRVAL_PP(ztype); + if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_stype", sizeof("enc_stype"), (void **)&ztype) == SUCCESS && + (Z_TYPE_PP(ztype) == IS_STRING || Z_TYPE_PP(ztype) == IS_UNICODE)) { + cur_stype = *ztype; } else { cur_stype = NULL; } - if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS) { - cur_ns = Z_STRVAL_PP(ztype); + if (zend_hash_find(Z_OBJPROP_PP(tmp), "enc_ns", sizeof("enc_ns"), (void **)&ztype) == SUCCESS && + (Z_TYPE_PP(ztype) == IS_STRING || Z_TYPE_PP(ztype) == IS_UNICODE)) { + cur_ns = *ztype; } else { cur_ns = NULL; } @@ -3246,15 +3296,54 @@ cur_ns = NULL; } + if (cur_stype) { + if (Z_TYPE_P(cur_stype) == IS_UNICODE) { + zval *tmp; + UErrorCode status = U_ZERO_ERROR; + + ALLOC_INIT_ZVAL(tmp); + Z_TYPE_P(tmp) = IS_STRING; + zend_convert_from_unicode(UG(utf8_conv), &Z_STRVAL_P(tmp), &Z_STRLEN_P(tmp), Z_USTRVAL_P(cur_stype), Z_USTRLEN_P(cur_stype), &status); + cur_stype = tmp; + } else { + cur_stype->refcount++; + } + } + if (cur_ns) { + if (Z_TYPE_P(cur_ns) == IS_UNICODE) { + zval *tmp; + UErrorCode status = U_ZERO_ERROR; + + ALLOC_INIT_ZVAL(tmp); + Z_TYPE_P(tmp) = IS_STRING; + zend_convert_from_unicode(UG(utf8_conv), &Z_STRVAL_P(tmp), &Z_STRLEN_P(tmp), Z_USTRVAL_P(cur_ns), Z_USTRLEN_P(cur_ns), &status); + cur_ns = tmp; + } else { + cur_ns->refcount++; + } + } + if (i > 0) { if ((cur_type != prev_type) || - (cur_stype != NULL && prev_stype != NULL && strcmp(cur_stype,prev_stype) != 0) || + (cur_stype != NULL && prev_stype != NULL && strcmp(Z_STRVAL_P(cur_stype),Z_STRVAL_P(prev_stype)) != 0) || (cur_stype == NULL && cur_stype != prev_stype) || - (cur_ns != NULL && prev_ns != NULL && strcmp(cur_ns,prev_ns) != 0) || + (cur_ns != NULL && prev_ns != NULL && strcmp(Z_STRVAL_P(cur_ns), Z_STRVAL_P(prev_ns)) != 0) || (cur_ns == NULL && cur_ns != prev_ns)) { different = TRUE; + if (prev_stype) { + zval_ptr_dtor(&prev_stype); + } + if (prev_ns) { + zval_ptr_dtor(&prev_ns); + } break; } + if (prev_stype) { + zval_ptr_dtor(&prev_stype); + } + if (prev_ns) { + zval_ptr_dtor(&prev_ns); + } } prev_type = cur_type; @@ -3273,24 +3362,33 @@ smart_str array_type = {0}; if (cur_ns) { - xmlNsPtr ns = encode_add_ns(node,cur_ns); + xmlNsPtr ns = encode_add_ns(node, Z_STRVAL_P(cur_ns)); smart_str_appends(type, (char*)ns->prefix); smart_str_appendc(type, ':'); - smart_str_appends(&array_type, cur_ns); + smart_str_appends(&array_type, Z_STRVAL_P(cur_ns)); smart_str_appendc(&array_type, ':'); } - smart_str_appends(type, cur_stype); + smart_str_appends(type, Z_STRVAL_P(cur_stype)); smart_str_0(type); - smart_str_appends(&array_type, cur_stype); + smart_str_appends(&array_type, Z_STRVAL_P(cur_stype)); smart_str_0(&array_type); enc = get_encoder_ex(SOAP_GLOBAL(sdl), array_type.c, array_type.len); smart_str_free(&array_type); + if (cur_stype) { + zval_ptr_dtor(&cur_stype); + } + if (cur_ns) { + zval_ptr_dtor(&cur_ns); + } return enc; } else { enc = get_conversion(cur_type); get_type_str(node, enc->details.ns, enc->details.type_str, type); + if (cur_ns) { + zval_ptr_dtor(&cur_ns); + } return enc; } } http://cvs.php.net/viewvc.cgi/php-src/ext/soap/soap.c?r1=1.195&r2=1.196&diff_format=u Index: php-src/ext/soap/soap.c diff -u php-src/ext/soap/soap.c:1.195 php-src/ext/soap/soap.c:1.196 --- php-src/ext/soap/soap.c:1.195 Thu Jul 13 16:47:25 2006 +++ php-src/ext/soap/soap.c Tue Jul 18 15:05:07 2006 @@ -17,7 +17,7 @@ | Dmitry Stogov <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: soap.c,v 1.195 2006/07/13 16:47:25 dmitry Exp $ */ +/* $Id: soap.c,v 1.196 2006/07/18 15:05:07 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -748,10 +748,11 @@ PHP_METHOD(SoapParam, SoapParam) { zval *data; - char *name; + zstr name; int name_length; + zend_uchar name_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &data, &name, &name_length) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zt", &data, &name, &name_length, &name_type) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); } if (name_length == 0) { @@ -761,7 +762,11 @@ #ifndef ZEND_ENGINE_2 zval_add_ref(&data); #endif - add_property_stringl(this_ptr, "param_name", name, name_length, 1); + if (name_type == IS_STRING) { + add_property_stringl(this_ptr, "param_name", name.s, name_length, 1); + } else { + add_property_unicodel(this_ptr, "param_name", name.u, name_length, 1); + } add_property_zval(this_ptr, "param_data", data); } /* }}} */ @@ -772,11 +777,14 @@ PHP_METHOD(SoapHeader, SoapHeader) { zval *data = NULL, *actor = NULL; - char *name, *ns; + zstr name, ns; int name_len, ns_len; + zend_uchar name_type, ns_type; zend_bool must_understand = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zbz", &ns, &ns_len, &name, &name_len, &data, &must_understand, &actor) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "tt|zbz", + &ns, &ns_len, &ns_type, &name, &name_len, &name_type, + &data, &must_understand, &actor) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); } if (ns_len == 0) { @@ -786,8 +794,16 @@ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid header name."); } - add_property_stringl(this_ptr, "namespace", ns, ns_len, 1); - add_property_stringl(this_ptr, "name", name, name_len, 1); + if (ns_type == IS_STRING) { + add_property_stringl(this_ptr, "namespace", ns.s, ns_len, 1); + } else { + add_property_unicodel(this_ptr, "namespace", ns.u, ns_len, 1); + } + if (name_type == IS_STRING) { + add_property_stringl(this_ptr, "name", name.s, name_len, 1); + } else { + add_property_unicodel(this_ptr, "name", name.u, name_len, 1); + } if (data) { #ifndef ZEND_ENGINE_2 zval_add_ref(&data); @@ -803,6 +819,8 @@ add_property_long(this_ptr, "actor", Z_LVAL_P(actor)); } else if (Z_TYPE_P(actor) == IS_STRING && Z_STRLEN_P(actor) > 0) { add_property_stringl(this_ptr, "actor", Z_STRVAL_P(actor), Z_STRLEN_P(actor), 1); + } else if (Z_TYPE_P(actor) == IS_UNICODE && Z_USTRLEN_P(actor) > 0) { + add_property_unicodel(this_ptr, "actor", Z_USTRVAL_P(actor), Z_USTRLEN_P(actor), 1); } else { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid actor."); } @@ -954,10 +972,16 @@ PHP_METHOD(SoapVar, SoapVar) { zval *data, *type; - char *stype = NULL, *ns = NULL, *name = NULL, *namens = NULL; + zstr stype = NULL_ZSTR, ns = NULL_ZSTR, name = NULL_ZSTR, namens = NULL_ZSTR; int stype_len, ns_len, name_len, namens_len; + zend_uchar stype_type, ns_type, name_type, namens_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!z|ssss", &data, &type, &stype, &stype_len, &ns, &ns_len, &name, &name_len, &namens, &namens_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!z|tttt", + &data, &type, + &stype, &stype_len, &stype_type, + &ns, &ns_len, &ns_type, + &name, &name_len, &name_type, + &namens, &namens_len, &namens_type) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters"); } @@ -978,17 +1002,33 @@ add_property_zval(this_ptr, "enc_value", data); } - if (stype && stype_len > 0) { - add_property_stringl(this_ptr, "enc_stype", stype, stype_len, 1); - } - if (ns && ns_len > 0) { - add_property_stringl(this_ptr, "enc_ns", ns, ns_len, 1); - } - if (name && name_len > 0) { - add_property_stringl(this_ptr, "enc_name", name, name_len, 1); - } - if (namens && namens_len > 0) { - add_property_stringl(this_ptr, "enc_namens", namens, namens_len, 1); + if (stype.v && stype_len > 0) { + if (stype_type == IS_STRING) { + add_property_stringl(this_ptr, "enc_stype", stype.s, stype_len, 1); + } else if (stype_type == IS_UNICODE) { + add_property_unicodel(this_ptr, "enc_stype", stype.u, stype_len, 1); + } + } + if (ns.v && ns_len > 0) { + if (ns_type == IS_STRING) { + add_property_stringl(this_ptr, "enc_ns", ns.s, ns_len, 1); + } else if (ns_type == IS_UNICODE) { + add_property_unicodel(this_ptr, "enc_ns", ns.u, ns_len, 1); + } + } + if (name.v && name_len > 0) { + if (name_type == IS_STRING) { + add_property_stringl(this_ptr, "enc_name", name.s, name_len, 1); + } else if (name_type == IS_UNICODE) { + add_property_unicodel(this_ptr, "enc_name", name.u, name_len, 1); + } + } + if (namens.v && namens_len > 0) { + if (namens_type == IS_STRING) { + add_property_stringl(this_ptr, "enc_namens", namens.s, namens_len, 1); + } else if (namens_type == IS_UNICODE) { + add_property_unicodel(this_ptr, "enc_namens", namens.u, namens_len, 1); + } } } /* }}} */ @@ -3816,6 +3856,7 @@ zval *hdr_ret = *tmp; char *hdr_ns = headers->hdr?headers->hdr->ns:NULL; char *hdr_name = Z_STRVAL(headers->function_name); + int free_ns = 0, free_name = 0; head = xmlNewChild(envelope, ns, BAD_CAST("Header"), NULL); if (Z_TYPE_P(hdr_ret) == IS_OBJECT && @@ -3825,16 +3866,31 @@ sdlSoapBindingFunctionHeaderPtr *hdr; smart_str key = {0}; - if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS && - Z_TYPE_PP(tmp) == IS_STRING) { - smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); - smart_str_appendc(&key, ':'); - hdr_ns = Z_STRVAL_PP(tmp); + if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS) { + if (Z_TYPE_PP(tmp) == IS_STRING) { + smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); + smart_str_appendc(&key, ':'); + hdr_ns = Z_STRVAL_PP(tmp); + } else if (Z_TYPE_PP(tmp) == IS_UNICODE) { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_USTRLEN_PP(tmp) TSRMLS_CC); + + smart_str_appends(&key, str); + smart_str_appendc(&key, ':'); + hdr_ns = str; + free_ns = 1; + } } - if (zend_hash_find(ht, "name", sizeof("name"), (void**)&tmp) == SUCCESS && - Z_TYPE_PP(tmp) == IS_STRING) { - smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); - hdr_name = Z_STRVAL_PP(tmp); + if (zend_hash_find(ht, "name", sizeof("name"), (void**)&tmp) == SUCCESS) { + if (Z_TYPE_PP(tmp) == IS_STRING) { + smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); + hdr_name = Z_STRVAL_PP(tmp); + } else if (Z_TYPE_PP(tmp) == IS_UNICODE) { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_USTRLEN_PP(tmp) TSRMLS_CC); + + smart_str_appends(&key, str); + hdr_name = str; + free_name = 1; + } } smart_str_0(&key); if (headers->hdr && headers->hdr->headerfaults && @@ -3864,6 +3920,13 @@ xmlSetNs(xmlHdr, nsptr); } } + + if (free_ns) { + efree(hdr_ns); + } + if (free_name) { + efree(hdr_name); + } } body = xmlNewChild(envelope, ns, BAD_CAST("Body"), NULL); @@ -4033,7 +4096,7 @@ zval *hdr_ret = &h->retval; char *hdr_ns = h->hdr?h->hdr->ns:NULL; char *hdr_name = Z_STRVAL(h->function_name); - + int free_ns = 0, free_name = 0; if (Z_TYPE(h->retval) == IS_OBJECT && instanceof_function(Z_OBJCE(h->retval), soap_header_class_entry TSRMLS_CC)) { @@ -4042,16 +4105,31 @@ sdlSoapBindingFunctionHeaderPtr *hdr; smart_str key = {0}; - if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS && - Z_TYPE_PP(tmp) == IS_STRING) { - smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); - smart_str_appendc(&key, ':'); - hdr_ns = Z_STRVAL_PP(tmp); + if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS) { + if (Z_TYPE_PP(tmp) == IS_STRING) { + smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); + smart_str_appendc(&key, ':'); + hdr_ns = Z_STRVAL_PP(tmp); + } else if (Z_TYPE_PP(tmp) == IS_UNICODE) { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_USTRLEN_PP(tmp) TSRMLS_CC); + + smart_str_appends(&key, str); + smart_str_appendc(&key, ':'); + hdr_ns = str; + free_ns = 1; + } } - if (zend_hash_find(ht, "name", sizeof("name"), (void**)&tmp) == SUCCESS && - Z_TYPE_PP(tmp) == IS_STRING) { - smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); - hdr_name = Z_STRVAL_PP(tmp); + if (zend_hash_find(ht, "name", sizeof("name"), (void**)&tmp) == SUCCESS) { + if (Z_TYPE_PP(tmp) == IS_STRING) { + smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); + hdr_name = Z_STRVAL_PP(tmp); + } else if (Z_TYPE_PP(tmp) == IS_UNICODE) { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_USTRLEN_PP(tmp) TSRMLS_CC); + + smart_str_appends(&key, str); + hdr_name = str; + free_name = 1; + } } smart_str_0(&key); if (function && function->binding && function->binding->bindingType == BINDING_SOAP) { @@ -4085,6 +4163,13 @@ xmlSetNs(xmlHdr, nsptr); } } + + if (free_ns) { + efree(hdr_ns); + } + if (free_name) { + efree(hdr_name); + } } h = h->next; } @@ -4242,21 +4327,36 @@ zval **name, **ns, **tmp; if (zend_hash_find(ht, "name", sizeof("name"), (void**)&name) == SUCCESS && - Z_TYPE_PP(name) == IS_STRING && + (Z_TYPE_PP(name) == IS_STRING || Z_TYPE_PP(name) == IS_UNICODE) && zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&ns) == SUCCESS && - Z_TYPE_PP(ns) == IS_STRING) { + (Z_TYPE_PP(ns) == IS_STRING || Z_TYPE_PP(ns) == IS_UNICODE)) { xmlNodePtr h; - xmlNsPtr nsptr; + xmlNsPtr nsptr = NULL; int hdr_use = SOAP_LITERAL; encodePtr enc = NULL; + char *name_str = NULL, *ns_str = NULL; if (hdrs) { smart_str key = {0}; sdlSoapBindingFunctionHeaderPtr *hdr; - smart_str_appendl(&key, Z_STRVAL_PP(ns), Z_STRLEN_PP(ns)); + if (Z_TYPE_PP(ns) == IS_STRING) { + smart_str_appendl(&key, Z_STRVAL_PP(ns), Z_STRLEN_PP(ns)); + } else { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(ns), Z_USTRLEN_PP(ns) TSRMLS_CC); + + smart_str_appends(&key, str); + ns_str = str; + } smart_str_appendc(&key, ':'); - smart_str_appendl(&key, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); + if (Z_TYPE_PP(name) == IS_STRING) { + smart_str_appendl(&key, Z_STRVAL_PP(name), Z_STRLEN_PP(name)); + } else { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(name), Z_USTRLEN_PP(name) TSRMLS_CC); + + smart_str_appends(&key, str); + name_str = str; + } smart_str_0(&key); if (zend_hash_find(hdrs, key.c, key.len+1,(void**)&hdr) == SUCCESS) { hdr_use = (*hdr)->use; @@ -4266,18 +4366,33 @@ } } smart_str_free(&key); + } else { + if (Z_TYPE_PP(ns) == IS_UNICODE) { + ns_str = soap_unicode_to_string(Z_USTRVAL_PP(ns), Z_USTRLEN_PP(ns) TSRMLS_CC); + } + if (Z_TYPE_PP(name) == IS_UNICODE) { + name_str = soap_unicode_to_string(Z_USTRVAL_PP(name), Z_USTRLEN_PP(name) TSRMLS_CC); + } } if (zend_hash_find(ht, "data", sizeof("data"), (void**)&tmp) == SUCCESS) { h = master_to_xml(enc, *tmp, hdr_use, head); - xmlNodeSetName(h, BAD_CAST(Z_STRVAL_PP(name))); + xmlNodeSetName(h, BAD_CAST(name_str?name_str:Z_STRVAL_PP(name))); } else { - h = xmlNewNode(NULL, BAD_CAST(Z_STRVAL_PP(name))); + h = xmlNewNode(NULL, BAD_CAST(name_str?name_str:Z_STRVAL_PP(name))); xmlAddChild(head, h); } - nsptr = encode_add_ns(h, Z_STRVAL_PP(ns)); + + nsptr = encode_add_ns(h, ns_str?ns_str:Z_STRVAL_PP(ns)); xmlSetNs(h, nsptr); + if (name_str) { + efree(name_str); + } + if (ns_str) { + efree(ns_str); + } + if (zend_hash_find(ht, "mustUnderstand", sizeof("mustUnderstand"), (void**)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_BOOL && Z_LVAL_PP(tmp)) { if (version == SOAP_1_1) { @@ -4293,6 +4408,15 @@ } else { xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(Z_STRVAL_PP(tmp))); } + } else if (Z_TYPE_PP(tmp) == IS_UNICODE) { + char *str = soap_unicode_to_string(Z_USTRVAL_PP(tmp), Z_STRLEN_PP(tmp) TSRMLS_CC); + + if (version == SOAP_1_1) { + xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(str)); + } else { + xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(str)); + } + efree(str); } else if (Z_TYPE_PP(tmp) == IS_LONG) { if (version == SOAP_1_1) { if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) { @@ -4335,6 +4459,7 @@ char *paramName; xmlNodePtr xmlParam; char paramNameBuf[10]; + int free_name = 0; if (param_val && Z_TYPE_P(param_val) == IS_OBJECT && @@ -4343,9 +4468,15 @@ zval **param_data; if (zend_hash_find(Z_OBJPROP_P(param_val), "param_name", sizeof("param_name"), (void **)¶m_name) == SUCCESS && + (Z_TYPE_PP(param_name) == IS_STRING || Z_TYPE_PP(param_name) == IS_UNICODE) && zend_hash_find(Z_OBJPROP_P(param_val), "param_data", sizeof("param_data"), (void **)¶m_data) == SUCCESS) { param_val = *param_data; - name = Z_STRVAL_PP(param_name); + if (Z_TYPE_PP(param_name) == IS_STRING) { + name = Z_STRVAL_PP(param_name); + } else { + name = soap_unicode_to_string(Z_USTRVAL_PP(param_name), Z_USTRLEN_PP(param_name) TSRMLS_CC); + free_name = 1; + } } } @@ -4362,6 +4493,10 @@ xmlParam = serialize_zval(param_val, param, paramName, style, parent TSRMLS_CC); + if (free_name) { + efree(name); + } + return xmlParam; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php