]> granicus.if.org Git - php/commitdiff
Allow unicode XML
authorDmitry Stogov <dmitry@php.net>
Mon, 2 Jul 2007 11:53:08 +0000 (11:53 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 2 Jul 2007 11:53:08 +0000 (11:53 +0000)
ext/simplexml/simplexml.c

index 7b0b9bc08ab86cbd8b4d7d211c6b1f1f19530dd8..d9c577efd493e13295bc37d970642e3738595409 100644 (file)
@@ -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) {