From: Dmitry Stogov Date: Mon, 2 Jul 2007 11:53:08 +0000 (+0000) Subject: Allow unicode XML X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~331 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a666b716698b3570eb4d7b6191d848eb9bd092a;p=php Allow unicode XML --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 7b0b9bc08a..d9c577efd4 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2110,7 +2110,8 @@ PHP_FUNCTION(simplexml_load_string) SXE_METHOD(__construct) { php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - char *data, *ns = NULL; + zstr data; + char *ns = NULL; int data_len, ns_len = 0; xmlDocPtr docp; long options = 0; @@ -2127,20 +2128,19 @@ SXE_METHOD(__construct) if (data_type == IS_UNICODE) { if (is_url) { - if (php_stream_path_encode(NULL, &data, &data_len, (UChar*)data, data_len, REPORT_ERRORS, NULL) == FAILURE) { + if (php_stream_path_encode(NULL, &data.s, &data_len, data.u, data_len, REPORT_ERRORS, NULL) == FAILURE) { zend_throw_exception(zend_exception_get_default(TSRMLS_C), "String could not be parsed as XML", 0 TSRMLS_CC); return; } } else { - zend_throw_exception(zend_exception_get_default(TSRMLS_C), "SimpleXMLElement can only parse a binary string", 0 TSRMLS_CC); - return; + data.s = php_libxml_unicode_to_string(data.u, data_len, &data_len TSRMLS_CC); } } - docp = is_url ? xmlReadFile(data, NULL, options) : xmlReadMemory(data, data_len, NULL, NULL, options); + docp = is_url ? xmlReadFile(data.s, NULL, options) : xmlReadMemory(data.s, data_len, NULL, NULL, options); - if (is_url && data_type == IS_UNICODE) { - efree(data); + if (data_type == IS_UNICODE) { + efree(data.s); } if (!docp) {