From: Rob Richards Date: Tue, 8 Aug 2006 20:52:45 +0000 (+0000) Subject: add unicode support X-Git-Tag: RELEASE_1_0_0RC1~2023 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3e906515cf24334bbdcab9b3687c9b9f2f2c11c;p=php add unicode support update tests (binary string must be passed to simplexml_load_string) --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 680c066442..44bb3c5205 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -254,7 +254,7 @@ static zval * sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, tmp_zv = *member; zval_copy_ctor(&tmp_zv); member = &tmp_zv; - convert_to_string(member); + convert_to_string_with_converter(member, UG(utf8_conv)); } name = Z_STRVAL_P(member); } @@ -383,7 +383,7 @@ static void change_node_zval(xmlNodePtr node, zval *value TSRMLS_DC) zval_copy_ctor(&value_copy); value = &value_copy; } - convert_to_string(value); + convert_to_string_with_converter(value, UG(utf8_conv)); /* break missing intentionally */ case IS_STRING: xmlNodeSetContentLen(node, (xmlChar *)Z_STRVAL_P(value), Z_STRLEN_P(value)); @@ -437,7 +437,7 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo if (Z_TYPE_P(member) != IS_STRING) { trim_zv = *member; zval_copy_ctor(&trim_zv); - convert_to_string(&trim_zv); + convert_to_string_with_converter(&trim_zv, UG(utf8_conv)); php_trim(Z_STRVAL(trim_zv), Z_STRLEN(trim_zv), NULL, 0, IS_STRING, &tmp_zv, 3 TSRMLS_CC); zval_dtor(&trim_zv); member = &tmp_zv; @@ -487,7 +487,7 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo zval_copy_ctor(&value_copy); value = &value_copy; } - convert_to_string(value); + convert_to_string_with_converter(value, UG(utf8_conv)); break; case IS_STRING: break; @@ -611,7 +611,8 @@ static zval** sxe_property_get_adr(zval *object, zval *member TSRMLS_DC) /* {{{ sxe = php_sxe_fetch_object(object TSRMLS_CC); GET_NODE(sxe, node); - convert_to_string(member); + convert_to_string_with_converter(member, UG(utf8_conv)); + name = Z_STRVAL_P(member); node = sxe_get_element_by_name(sxe, node, &name, &type TSRMLS_CC); if (!node) { @@ -645,7 +646,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend tmp_zv = *member; zval_copy_ctor(&tmp_zv); member = &tmp_zv; - convert_to_string(member); + convert_to_string_with_converter(member, UG(utf8_conv)); } sxe = php_sxe_fetch_object(object TSRMLS_CC); @@ -765,7 +766,7 @@ static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements, tmp_zv = *member; zval_copy_ctor(&tmp_zv); member = &tmp_zv; - convert_to_string(member); + convert_to_string_with_converter(member, UG(utf8_conv)); } sxe = php_sxe_fetch_object(object TSRMLS_CC); @@ -886,7 +887,7 @@ static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval if (node->children && node->children->type == XML_TEXT_NODE && !xmlIsBlankNode(node->children)) { contents = xmlNodeListGetString(node->doc, node->children, 1); if (contents) { - ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), *value, (char *)contents, 1); + ZVAL_XML_STRING(*value, (char *)contents, ZSTR_DUPLICATE); xmlFree(contents); } } else { @@ -971,7 +972,8 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC) xmlChar *tmp; MAKE_STD_ZVAL(value); - ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 1); + tmp = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1); + ZVAL_XML_STRING(value, (char *)tmp, ZSTR_DUPLICATE); xmlFree(tmp); namelen = xmlStrlen(attr->name) + 1; if (!zattr) { @@ -992,7 +994,8 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC) xmlChar *tmp; MAKE_STD_ZVAL(value); - ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = xmlNodeListGetString(node->doc, node->children, 1), 1); + tmp = xmlNodeListGetString(node->doc, node->children, 1); + ZVAL_XML_STRING(value, (char *)tmp, ZSTR_DUPLICATE); xmlFree(tmp); zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); node = NULL; @@ -1008,7 +1011,8 @@ static HashTable * sxe_properties_get(zval *object TSRMLS_DC) xmlChar *tmp; MAKE_STD_ZVAL(value); - ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), value, tmp = xmlNodeListGetString(node->doc, node, 1), 1); + tmp = xmlNodeListGetString(node->doc, node, 1); + ZVAL_XML_STRING(value, (char *)tmp, ZSTR_DUPLICATE); xmlFree(tmp); zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); goto next_iter; @@ -1059,7 +1063,7 @@ static int sxe_objects_compare(zval *object1, zval *object2 TSRMLS_DC) /* {{{ */ } /* }}} */ -/* {{{ proto array SimpleXMLElement::xpath(string path) +/* {{{ proto array SimpleXMLElement::xpath(string path) U Runs XPath query on the XML data */ SXE_METHOD(xpath) { @@ -1074,7 +1078,7 @@ SXE_METHOD(xpath) xmlNodeSetPtr result; xmlNodePtr nodeptr; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &query, &query_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&", &query, &query_len, UG(utf8_conv)) == FAILURE) { return; } @@ -1134,7 +1138,7 @@ SXE_METHOD(xpath) if (nodeptr->type == XML_TEXT_NODE) { _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC); } else if (nodeptr->type == XML_ATTRIBUTE_NODE) { - _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, NULL, 0 TSRMLS_CC); + _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char *)nodeptr->name, NULL, 0 TSRMLS_CC); } else { _node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC); } @@ -1146,7 +1150,7 @@ SXE_METHOD(xpath) xmlXPathFreeObject(retval); } -/* {{{ proto bool SimpleXMLElement::registerXPathNamespace(string prefix, string ns) +/* {{{ proto bool SimpleXMLElement::registerXPathNamespace(string prefix, string ns) U Creates a prefix/ns context for the next XPath query */ SXE_METHOD(registerXPathNamespace) { @@ -1154,7 +1158,7 @@ SXE_METHOD(registerXPathNamespace) int prefix_len, ns_uri_len; char *prefix, *ns_uri; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &prefix, &prefix_len, &ns_uri, &ns_uri_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&", &prefix, &prefix_len, UG(utf8_conv), &ns_uri, &ns_uri_len, UG(utf8_conv)) == FAILURE) { return; } @@ -1171,7 +1175,7 @@ SXE_METHOD(registerXPathNamespace) /* }}} */ -/* {{{ proto string SimpleXMLElement::asXML([string filename]) +/* {{{ proto string SimpleXMLElement::asXML([string filename]) U Return a well-formed XML string based on SimpleXML element */ SXE_METHOD(asXML) { @@ -1182,13 +1186,14 @@ SXE_METHOD(asXML) int strval_len; char *filename; int filename_len; + zend_uchar filename_type; if (ZEND_NUM_ARGS() > 1) { RETURN_FALSE; } if (ZEND_NUM_ARGS() == 1) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &filename, &filename_len, &filename_type) == FAILURE) { RETURN_FALSE; } @@ -1197,25 +1202,35 @@ SXE_METHOD(asXML) node = php_sxe_get_first_node(sxe, node TSRMLS_CC); if (node) { + if (filename_type == IS_UNICODE) { + if (php_stream_path_encode(NULL, &filename, &filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, NULL) == FAILURE) { + RETURN_FALSE; + } + } + if (XML_DOCUMENT_NODE == node->parent->type) { int bytes; bytes = xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr); if (bytes == -1) { - RETURN_FALSE; + RETVAL_FALSE; } else { - RETURN_TRUE; + RETVAL_TRUE; } } else { outbuf = xmlOutputBufferCreateFilename(filename, NULL, 0); if (outbuf == NULL) { - RETURN_FALSE; + RETVAL_FALSE; + } else { + xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, NULL); + xmlOutputBufferClose(outbuf); + RETVAL_TRUE; } - - xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, NULL); - xmlOutputBufferClose(outbuf); - RETURN_TRUE; } + if (filename_type == IS_UNICODE) { + efree(filename); + } + return; } else { RETURN_FALSE; } @@ -1251,11 +1266,24 @@ SXE_METHOD(asXML) #define SXE_NS_PREFIX(ns) (ns->prefix ? (char*)ns->prefix : "") -static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns) +static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns TSRMLS_DC) { + uint prefix_len; char *prefix = SXE_NS_PREFIX(ns); - if (zend_hash_exists(Z_ARRVAL_P(return_value), prefix, strlen(prefix) + 1) == 0) { - add_assoc_string(return_value, prefix, (char*)ns->href, 1); + + prefix_len = strlen(prefix) + 1; + + if (zend_hash_exists(Z_ARRVAL_P(return_value), prefix, prefix_len) == 0) { + if (UG(unicode)) { + UErrorCode status = U_ZERO_ERROR; + UChar *u_str; + int u_len; + int length = strlen((char*)ns->href); + zend_string_to_unicode_ex(UG(utf8_conv), &u_str, &u_len, (char*)ns->href, length, &status); + add_assoc_unicodel_ex(return_value, prefix, prefix_len, u_str, u_len, 0); + } else { + add_assoc_string_ex(return_value, prefix, prefix_len, (char*)ns->href, 1); + } } } @@ -1264,13 +1292,13 @@ static void sxe_add_namespaces(php_sxe_object *sxe, xmlNodePtr node, zend_bool r xmlAttrPtr attr; if (node->ns) { - sxe_add_namespace_name(return_value, node->ns); + sxe_add_namespace_name(return_value, node->ns TSRMLS_CC); } attr = node->properties; while (attr) { if (attr->ns) { - sxe_add_namespace_name(return_value, attr->ns); + sxe_add_namespace_name(return_value, attr->ns TSRMLS_CC); } attr = attr->next; } @@ -1309,7 +1337,7 @@ SXE_METHOD(getNamespaces) if (node->type == XML_ELEMENT_NODE) { sxe_add_namespaces(sxe, node, recursive, return_value TSRMLS_CC); } else if (node->type == XML_ATTRIBUTE_NODE && node->ns) { - sxe_add_namespace_name(return_value, node->ns); + sxe_add_namespace_name(return_value, node->ns TSRMLS_CC); } next_iter: node = node->next; @@ -1324,7 +1352,7 @@ static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr node, if (node->type == XML_ELEMENT_NODE) { ns = node->nsDef; while (ns != NULL) { - sxe_add_namespace_name(return_value, ns); + sxe_add_namespace_name(return_value, ns TSRMLS_CC); ns = ns->next; } if (recursive) { @@ -1357,7 +1385,7 @@ SXE_METHOD(getDocNamespaces) } /* }}} */ -/* {{{ proto object SimpleXMLElement::children([string ns [, bool is_prefix]]) +/* {{{ proto object SimpleXMLElement::children([string ns [, bool is_prefix]]) U Finds children of given node */ SXE_METHOD(children) { @@ -1367,7 +1395,7 @@ SXE_METHOD(children) xmlNodePtr node; zend_bool isprefix = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!b", &nsprefix, &nsprefix_len, &isprefix) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!&b", &nsprefix, &nsprefix_len, UG(utf8_conv), &isprefix) == FAILURE) { return; } @@ -1385,7 +1413,7 @@ SXE_METHOD(children) } /* }}} */ -/* {{{ proto object SimpleXMLElement::getName() +/* {{{ proto object SimpleXMLElement::getName() U Finds children of given node */ SXE_METHOD(getName) { @@ -1398,11 +1426,11 @@ SXE_METHOD(getName) GET_NODE(sxe, node); namelen = xmlStrlen(node->name); - RETURN_ASCII_STRINGL((char*)node->name, namelen, 1); + RETVAL_XML_STRING_LEN((char *) node->name, namelen, ZSTR_DUPLICATE); } /* }}} */ -/* {{{ proto array SimpleXMLElement::attributes([string ns [, bool is_prefix]]) +/* {{{ proto array SimpleXMLElement::attributes([string ns [, bool is_prefix]]) U Identifies an element's attributes */ SXE_METHOD(attributes) { @@ -1412,7 +1440,7 @@ SXE_METHOD(attributes) xmlNodePtr node; zend_bool isprefix = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!b", &nsprefix, &nsprefix_len, &isprefix) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!&b", &nsprefix, &nsprefix_len, UG(utf8_conv), &isprefix) == FAILURE) { return; } @@ -1429,7 +1457,7 @@ SXE_METHOD(attributes) } /* }}} */ -/* {{{ proto void SimpleXMLElement::addChild(string qName [, string value [, string ns]]) +/* {{{ proto void SimpleXMLElement::addChild(string qName [, string value [, string ns]]) U Add Element with optional namespace information */ SXE_METHOD(addChild) { @@ -1440,8 +1468,8 @@ SXE_METHOD(addChild) xmlNsPtr nsptr = NULL; xmlChar *localname, *prefix = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!s!", - &qname, &qname_len, &value, &value_len, &nsuri, &nsuri_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&|s!&s!&", + &qname, &qname_len, UG(utf8_conv), &value, &value_len, UG(utf8_conv), &nsuri, &nsuri_len, UG(utf8_conv)) == FAILURE) { return; } @@ -1484,7 +1512,7 @@ SXE_METHOD(addChild) } /* }}} */ -/* {{{ proto void SimpleXMLElement::addAttribute(string qName, string value [,string ns]) +/* {{{ proto void SimpleXMLElement::addAttribute(string qName, string value [,string ns]) U Add Attribute with optional namespace information */ SXE_METHOD(addAttribute) { @@ -1496,8 +1524,8 @@ SXE_METHOD(addAttribute) xmlNsPtr nsptr = NULL; xmlChar *localname, *prefix = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|s!", - &qname, &qname_len, &value, &value_len, &nsuri, &nsuri_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s&s&|s!&", + &qname, &qname_len, UG(utf8_conv), &value, &value_len, UG(utf8_conv), &nsuri, &nsuri_len, UG(utf8_conv)) == FAILURE) { return; } @@ -1556,11 +1584,7 @@ SXE_METHOD(addAttribute) static int cast_object(zval *object, int type, char *contents TSRMLS_DC) { if (contents) { - if (UG(unicode)) { - ZVAL_U_STRING(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), object, contents, 1); - } else { - ZVAL_STRINGL(object, contents, strlen(contents), 1); - } + ZVAL_XML_STRING(object, contents, ZSTR_DUPLICATE); } else { ZVAL_NULL(object); } @@ -1830,7 +1854,7 @@ sxe_object_new(zend_class_entry *ce TSRMLS_DC) } /* }}} */ -/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string class_name [, int options [, string ns [, bool is_prefix]]]]) +/* {{{ proto simplemxml_element simplexml_load_file(string filename [, string class_name [, int options [, string ns [, bool is_prefix]]]]) U Load a filename and return a simplexml_element object to allow for processing */ PHP_FUNCTION(simplexml_load_file) { @@ -1843,13 +1867,25 @@ PHP_FUNCTION(simplexml_load_file) long options = 0; zend_class_entry *ce= sxe_class_entry; zend_bool isprefix = 0; + zend_uchar filename_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|C!lsb", &filename, &filename_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|C!ls&b", &filename, &filename_len, &filename_type, &ce, &options, &ns, &ns_len, UG(utf8_conv), &isprefix) == FAILURE) { return; } + if (filename_type == IS_UNICODE) { + if (php_stream_path_encode(NULL, &filename, &filename_len, (UChar*)filename, filename_len, REPORT_ERRORS, NULL) == FAILURE) { + zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Could not encode filename", 0 TSRMLS_CC); + return; + } + } + docp = xmlReadFile(filename, NULL, options); + if (filename_type == IS_UNICODE) { + efree(filename); + } + if (! docp) { RETURN_FALSE; } @@ -1868,7 +1904,7 @@ PHP_FUNCTION(simplexml_load_file) } /* }}} */ -/* {{{ proto simplemxml_element simplexml_load_string(string data [, string class_name [, int options [, string ns [, bool is_prefix]]]]) +/* {{{ proto simplemxml_element simplexml_load_string(string data [, string class_name [, int options [, string ns [, bool is_prefix]]]]) U Load a string and return a simplexml_element object to allow for processing */ PHP_FUNCTION(simplexml_load_string) { @@ -1882,7 +1918,7 @@ PHP_FUNCTION(simplexml_load_string) zend_class_entry *ce= sxe_class_entry; zend_bool isprefix = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|C!lsb", &data, &data_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|C!ls&b", &data, &data_len, &ce, &options, &ns, &ns_len, UG(utf8_conv), &isprefix) == FAILURE) { return; } @@ -1907,7 +1943,7 @@ PHP_FUNCTION(simplexml_load_string) /* }}} */ -/* {{{ proto SimpleXMLElement::__construct(string data [, int options [, bool data_is_url [, string ns [, bool is_prefix]]]]) +/* {{{ proto SimpleXMLElement::__construct(string data [, int options [, bool data_is_url [, string ns [, bool is_prefix]]]]) U SimpleXMLElement constructor */ SXE_METHOD(__construct) { @@ -1917,17 +1953,34 @@ SXE_METHOD(__construct) xmlDocPtr docp; long options = 0; zend_bool is_url = 0, isprefix = 0; + zend_uchar data_type; php_set_error_handling(EH_THROW, zend_exception_get_default(TSRMLS_C) TSRMLS_CC); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lbsb", &data, &data_len, &options, &is_url, &ns, &ns_len, &isprefix) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|lbs&b", &data, &data_len, &data_type, &options, &is_url, &ns, &ns_len, UG(utf8_conv), &isprefix) == FAILURE) { php_std_error_handling(); return; } php_std_error_handling(); + 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) { + 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; + } + } + docp = is_url ? xmlReadFile(data, NULL, options) : xmlReadMemory(data, data_len, NULL, NULL, options); + if (is_url && data_type == IS_UNICODE) { + efree(data); + } + if (!docp) { ((php_libxml_node_object *)sxe)->document = NULL; zend_throw_exception(zend_exception_get_default(TSRMLS_C), "String could not be parsed as XML", 0 TSRMLS_CC); @@ -2080,12 +2133,12 @@ static int php_sxe_iterator_current_key(zend_object_iterator *iter, zstr *str_ke int u_len; namelen = xmlStrlen(curnode->name); - zend_string_to_unicode_ex(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &str_key->u, &u_len, (char*)curnode->name, namelen, &status); + zend_string_to_unicode_ex(UG(utf8_conv), &str_key->u, &u_len, (char*)curnode->name, namelen, &status); *str_key_len = u_len + 1; return HASH_KEY_IS_UNICODE; } else { namelen = xmlStrlen(curnode->name); - str_key->s = estrndup(curnode->name, namelen); + str_key->s = estrndup((char *)curnode->name, namelen); *str_key_len = namelen + 1; return HASH_KEY_IS_STRING; } @@ -2134,7 +2187,7 @@ void *simplexml_export_node(zval *object TSRMLS_DC) return php_sxe_get_first_node(sxe, node TSRMLS_CC); } -/* {{{ proto simplemxml_element simplexml_import_dom(domNode node [, string class_name]) +/* {{{ proto simplemxml_element simplexml_import_dom(domNode node [, string class_name]) U Get a simplexml_element object from dom to allow for processing */ PHP_FUNCTION(simplexml_import_dom) { diff --git a/ext/simplexml/tests/002.phpt b/ext/simplexml/tests/002.phpt index 6d1679faa4..f761f3740b 100644 --- a/ext/simplexml/tests/002.phpt +++ b/ext/simplexml/tests/002.phpt @@ -5,7 +5,7 @@ SimpleXML: clone --FILE-- diff --git a/ext/simplexml/tests/003.phpt b/ext/simplexml/tests/003.phpt index 9cb5c0e5dc..75376a1538 100755 --- a/ext/simplexml/tests/003.phpt +++ b/ext/simplexml/tests/003.phpt @@ -5,7 +5,7 @@ SimpleXML: Entities --FILE-- diff --git a/ext/simplexml/tests/004.phpt b/ext/simplexml/tests/004.phpt index bb5916440b..a94003422c 100755 --- a/ext/simplexml/tests/004.phpt +++ b/ext/simplexml/tests/004.phpt @@ -5,7 +5,7 @@ SimpleXML: CDATA --FILE-- diff --git a/ext/simplexml/tests/005.phpt b/ext/simplexml/tests/005.phpt index fc24b903ac..035d66b545 100755 --- a/ext/simplexml/tests/005.phpt +++ b/ext/simplexml/tests/005.phpt @@ -5,7 +5,7 @@ SimpleXML: Text data --FILE-- diff --git a/ext/simplexml/tests/006.phpt b/ext/simplexml/tests/006.phpt index 372f38fb03..b97b71f845 100755 --- a/ext/simplexml/tests/006.phpt +++ b/ext/simplexml/tests/006.phpt @@ -5,7 +5,7 @@ SimpleXML: foreach --FILE-- diff --git a/ext/simplexml/tests/007.phpt b/ext/simplexml/tests/007.phpt index 5a2cf6f9c0..6708947790 100755 --- a/ext/simplexml/tests/007.phpt +++ b/ext/simplexml/tests/007.phpt @@ -5,7 +5,7 @@ SimpleXML: Attributes --FILE-- diff --git a/ext/simplexml/tests/008.phpt b/ext/simplexml/tests/008.phpt index aaa2759aca..82dc783276 100644 --- a/ext/simplexml/tests/008.phpt +++ b/ext/simplexml/tests/008.phpt @@ -5,7 +5,7 @@ SimpleXML: XPath --FILE-- diff --git a/ext/simplexml/tests/009.phpt b/ext/simplexml/tests/009.phpt index 7663f6a92b..d5cd99910e 100755 --- a/ext/simplexml/tests/009.phpt +++ b/ext/simplexml/tests/009.phpt @@ -4,7 +4,7 @@ SimpleXML: foreach --FILE-- diff --git a/ext/simplexml/tests/009b.phpt b/ext/simplexml/tests/009b.phpt index 3695d34dfc..de3c522d3a 100755 --- a/ext/simplexml/tests/009b.phpt +++ b/ext/simplexml/tests/009b.phpt @@ -4,7 +4,7 @@ SimpleXML: foreach --FILE-- diff --git a/ext/simplexml/tests/010.phpt b/ext/simplexml/tests/010.phpt index 5318a525a3..0b4da340fc 100644 --- a/ext/simplexml/tests/010.phpt +++ b/ext/simplexml/tests/010.phpt @@ -9,7 +9,7 @@ class simplexml_inherited extends SimpleXMLElement { } -$xml =<< diff --git a/ext/simplexml/tests/011.phpt b/ext/simplexml/tests/011.phpt index 74ea4705ca..4404031f33 100755 --- a/ext/simplexml/tests/011.phpt +++ b/ext/simplexml/tests/011.phpt @@ -7,7 +7,7 @@ SimpleXML: echo/print --FILE-- bar diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt index 2fc9bec41e..f02c3fb167 100755 --- a/ext/simplexml/tests/012.phpt +++ b/ext/simplexml/tests/012.phpt @@ -7,7 +7,7 @@ SimpleXML: Attribute creation --FILE-- EOF; diff --git a/ext/simplexml/tests/013.phpt b/ext/simplexml/tests/013.phpt index bfb91dbcf9..1ce464766c 100755 --- a/ext/simplexml/tests/013.phpt +++ b/ext/simplexml/tests/013.phpt @@ -7,7 +7,7 @@ SimpleXML: Split text content --FILE-- barbar EOF; diff --git a/ext/simplexml/tests/014.phpt b/ext/simplexml/tests/014.phpt index ba5097598b..0342ee972b 100644 --- a/ext/simplexml/tests/014.phpt +++ b/ext/simplexml/tests/014.phpt @@ -4,7 +4,7 @@ SimpleXML: adding/removing attributes (direct) --FILE-- diff --git a/ext/simplexml/tests/014a.phpt b/ext/simplexml/tests/014a.phpt index 59315f884e..aa4eaa4ffb 100755 --- a/ext/simplexml/tests/014a.phpt +++ b/ext/simplexml/tests/014a.phpt @@ -4,7 +4,7 @@ SimpleXML: adding/removing attributes (single) --FILE-- diff --git a/ext/simplexml/tests/014b.phpt b/ext/simplexml/tests/014b.phpt index 04bcb75224..155dfa6db1 100755 --- a/ext/simplexml/tests/014b.phpt +++ b/ext/simplexml/tests/014b.phpt @@ -4,7 +4,7 @@ SimpleXML: adding/removing attributes (second) --FILE-- diff --git a/ext/simplexml/tests/015.phpt b/ext/simplexml/tests/015.phpt index aa827d72d8..2b3f7d18ae 100644 --- a/ext/simplexml/tests/015.phpt +++ b/ext/simplexml/tests/015.phpt @@ -4,13 +4,13 @@ SimpleXML: accessing singular subnode as array --FILE-- EOF; -$xml2 =<< diff --git a/ext/simplexml/tests/016.phpt b/ext/simplexml/tests/016.phpt index 87b9a0ef98..529f515d0b 100644 --- a/ext/simplexml/tests/016.phpt +++ b/ext/simplexml/tests/016.phpt @@ -4,7 +4,7 @@ SimpleXML: modifying attributes of singular subnode --FILE-- diff --git a/ext/simplexml/tests/016a.phpt b/ext/simplexml/tests/016a.phpt index aa9ad53064..6ef8d917d9 100755 --- a/ext/simplexml/tests/016a.phpt +++ b/ext/simplexml/tests/016a.phpt @@ -4,7 +4,7 @@ SimpleXML: concatenating attributes --FILE-- diff --git a/ext/simplexml/tests/017.phpt b/ext/simplexml/tests/017.phpt index 776b00c785..8927bdde48 100644 --- a/ext/simplexml/tests/017.phpt +++ b/ext/simplexml/tests/017.phpt @@ -4,7 +4,7 @@ SimpleXML: iteration through subnodes --FILE-- @@ -16,7 +16,7 @@ $xml =<< EOF; -$xml1 =<< diff --git a/ext/simplexml/tests/018.phpt b/ext/simplexml/tests/018.phpt index e5c810944e..9e1bd41c4f 100644 --- a/ext/simplexml/tests/018.phpt +++ b/ext/simplexml/tests/018.phpt @@ -4,7 +4,7 @@ SimpleXML: iteration through subnodes and attributes --FILE-- Text1 @@ -19,7 +19,7 @@ $xml =<< EOF; -$xml1 =<< diff --git a/ext/simplexml/tests/019.phpt b/ext/simplexml/tests/019.phpt index 2f58707d7d..d69ba5f658 100755 --- a/ext/simplexml/tests/019.phpt +++ b/ext/simplexml/tests/019.phpt @@ -5,7 +5,7 @@ SimpleXML: foreach with children() --FILE-- diff --git a/ext/simplexml/tests/020.phpt b/ext/simplexml/tests/020.phpt index 9e91b5ac3a..7b55d70074 100755 --- a/ext/simplexml/tests/020.phpt +++ b/ext/simplexml/tests/020.phpt @@ -4,8 +4,7 @@ SimpleXML: Attribute compared to string --FILE-- bar'); +$doc = simplexml_load_string(b'bar'); print $doc->name["attr"]; print "\n"; if ($doc->name["attr"] == "foo") { diff --git a/ext/simplexml/tests/021.phpt b/ext/simplexml/tests/021.phpt index d5138685f5..7493975ee1 100644 --- a/ext/simplexml/tests/021.phpt +++ b/ext/simplexml/tests/021.phpt @@ -6,7 +6,7 @@ SimpleXML: Element check foo'); +$doc = simplexml_load_string(b'foo'); if(!isset($doc->exists)) { $ok *= 0; } diff --git a/ext/simplexml/tests/022.phpt b/ext/simplexml/tests/022.phpt index 5374bbaa2d..a3586f1b39 100755 --- a/ext/simplexml/tests/022.phpt +++ b/ext/simplexml/tests/022.phpt @@ -5,7 +5,7 @@ SimpleXML: Attributes inside foreach --FILE-- EOF; diff --git a/ext/simplexml/tests/023.phpt b/ext/simplexml/tests/023.phpt index be82b78f38..1aa47b3be4 100755 --- a/ext/simplexml/tests/023.phpt +++ b/ext/simplexml/tests/023.phpt @@ -5,7 +5,7 @@ SimpleXML: Attributes with entities --FILE-- diff --git a/ext/simplexml/tests/024.phpt b/ext/simplexml/tests/024.phpt index 018d7e50b6..7cbe3d43e1 100755 --- a/ext/simplexml/tests/024.phpt +++ b/ext/simplexml/tests/024.phpt @@ -5,7 +5,7 @@ SimpleXML: XPath and attributes --FILE-- diff --git a/ext/simplexml/tests/025.phpt b/ext/simplexml/tests/025.phpt index 8579a1e09f..e763d6e22e 100755 --- a/ext/simplexml/tests/025.phpt +++ b/ext/simplexml/tests/025.phpt @@ -5,7 +5,7 @@ SimpleXML: getting namespaces --FILE-- bla @@ -23,7 +23,7 @@ var_dump($sxe->getNamespaces(true)); var_dump($sxe->getDocNamespaces()); var_dump($sxe->getDocNamespaces(true)); -$xml =<< bla @@ -35,7 +35,7 @@ $sxe = simplexml_load_string($xml); var_dump($sxe->getNamespaces()); var_dump($sxe->getDocNamespaces()); -$xml =<< EOF; @@ -93,39 +93,39 @@ array(0) { --UEXPECTF-- array(1) { [u"xhtml"]=> - string(31) "http://www.w3.org/TR/REC-html40" + unicode(31) "http://www.w3.org/TR/REC-html40" } array(3) { [u"xhtml"]=> - string(31) "http://www.w3.org/TR/REC-html40" + unicode(31) "http://www.w3.org/TR/REC-html40" [u"html"]=> - string(28) "http://www.w3.org/1999/xhtml" + unicode(28) "http://www.w3.org/1999/xhtml" [u"foo"]=> - string(6) "foobar" + unicode(6) "foobar" } array(2) { [u"html"]=> - string(28) "http://www.w3.org/1999/xhtml" + unicode(28) "http://www.w3.org/1999/xhtml" [u"xhtml"]=> - string(31) "http://www.w3.org/TR/REC-html40" + unicode(31) "http://www.w3.org/TR/REC-html40" } array(4) { [u"html"]=> - string(28) "http://www.w3.org/1999/xhtml" + unicode(28) "http://www.w3.org/1999/xhtml" [u"xhtml"]=> - string(31) "http://www.w3.org/TR/REC-html40" + unicode(31) "http://www.w3.org/TR/REC-html40" [u"foo"]=> - string(6) "foobar" + unicode(6) "foobar" [u"baz"]=> - string(9) "foobarbaz" + unicode(9) "foobarbaz" } array(1) { [u""]=> - string(28) "http://www.w3.org/1999/xhtml" + unicode(28) "http://www.w3.org/1999/xhtml" } array(1) { [u""]=> - string(28) "http://www.w3.org/1999/xhtml" + unicode(28) "http://www.w3.org/1999/xhtml" } array(0) { } diff --git a/ext/simplexml/tests/026.phpt b/ext/simplexml/tests/026.phpt index d6de94be3d..fb5f85c850 100755 --- a/ext/simplexml/tests/026.phpt +++ b/ext/simplexml/tests/026.phpt @@ -4,7 +4,7 @@ SimpleXML: getName() --FILE-- Jane diff --git a/ext/simplexml/tests/027.phpt b/ext/simplexml/tests/027.phpt index f32786c7cc..b6d573171b 100755 --- a/ext/simplexml/tests/027.phpt +++ b/ext/simplexml/tests/027.phpt @@ -4,7 +4,7 @@ SimpleXML: Adding an elements --FILE-- EOF; diff --git a/ext/simplexml/tests/028.phpt b/ext/simplexml/tests/028.phpt index 753056b9ad..422804a487 100755 --- a/ext/simplexml/tests/028.phpt +++ b/ext/simplexml/tests/028.phpt @@ -4,7 +4,7 @@ SimpleXML: Adding an elements without text --FILE-- EOF; diff --git a/ext/simplexml/tests/029.phpt b/ext/simplexml/tests/029.phpt index 1624b12d50..0a2fe0e429 100755 --- a/ext/simplexml/tests/029.phpt +++ b/ext/simplexml/tests/029.phpt @@ -4,7 +4,7 @@ SimpleXML: foreach and count --FILE-- diff --git a/ext/simplexml/tests/030.phpt b/ext/simplexml/tests/030.phpt index 774a5f1459..856bf49f4e 100644 --- a/ext/simplexml/tests/030.phpt +++ b/ext/simplexml/tests/030.phpt @@ -4,7 +4,7 @@ SimpleXML: isset and unset by offset --FILE-- test diff --git a/ext/simplexml/tests/031.phpt b/ext/simplexml/tests/031.phpt index 28d87b0a38..e2816fa207 100644 --- a/ext/simplexml/tests/031.phpt +++ b/ext/simplexml/tests/031.phpt @@ -4,7 +4,7 @@ SimpleXML: addChild and addAttribute --FILE-- test diff --git a/ext/simplexml/tests/032.phpt b/ext/simplexml/tests/032.phpt index 48bc887ecc..60d9aad152 100755 --- a/ext/simplexml/tests/032.phpt +++ b/ext/simplexml/tests/032.phpt @@ -4,7 +4,7 @@ SimpleXML: comparing instances --FILE-- @@ -16,7 +16,7 @@ $xml =<< EOF; -$xml1 =<< diff --git a/ext/simplexml/tests/033.phpt b/ext/simplexml/tests/033.phpt index b0ee633881..761374424b 100755 --- a/ext/simplexml/tests/033.phpt +++ b/ext/simplexml/tests/033.phpt @@ -5,7 +5,7 @@ SimpleXML: casting instances --FILE-- test @@ -18,7 +18,7 @@ test EOF; -$foo = simplexml_load_string( "" ); +$foo = simplexml_load_string( b"" ); $people = simplexml_load_string($xml); var_dump((bool)$foo); diff --git a/ext/simplexml/tests/bug26976.phpt b/ext/simplexml/tests/bug26976.phpt index 657c229737..a109c63392 100644 --- a/ext/simplexml/tests/bug26976.phpt +++ b/ext/simplexml/tests/bug26976.phpt @@ -6,7 +6,7 @@ Bug #26976 (Can not access array elements using array indices) +b' a b diff --git a/ext/simplexml/tests/bug27010.phpt b/ext/simplexml/tests/bug27010.phpt index 364ca4675f..8005da2c3a 100755 --- a/ext/simplexml/tests/bug27010.phpt +++ b/ext/simplexml/tests/bug27010.phpt @@ -5,7 +5,7 @@ Bug #27010 (segfault and node text not displayed when returned from children()) --FILE-- Coffee Tea diff --git a/ext/simplexml/tests/bug35785.phpt b/ext/simplexml/tests/bug35785.phpt index 096ab7a681..a9c718b954 100755 --- a/ext/simplexml/tests/bug35785.phpt +++ b/ext/simplexml/tests/bug35785.phpt @@ -5,13 +5,13 @@ Bug #35785 (SimpleXML memory read error) --FILE-- "); +$xml = simplexml_load_string(b""); $xml->bla->posts->name = "FooBar"; echo $xml->asXML(); echo "===FAIL===\n"; -$xml = simplexml_load_string(""); +$xml = simplexml_load_string(b""); $count = count($xml->bla->posts); var_dump($count); $xml->bla->posts[++$count]->name = "FooBar"; diff --git a/ext/simplexml/tests/bug36611.phpt b/ext/simplexml/tests/bug36611.phpt index 835e926fe5..264eb1fbb3 100644 --- a/ext/simplexml/tests/bug36611.phpt +++ b/ext/simplexml/tests/bug36611.phpt @@ -5,7 +5,7 @@ Bug #36611 (assignment to SimpleXML object attribute changes argument type to st --FILE-- diff --git a/ext/simplexml/tests/bug37565.phpt b/ext/simplexml/tests/bug37565.phpt index 811b335ed1..572cc35f76 100755 --- a/ext/simplexml/tests/bug37565.phpt +++ b/ext/simplexml/tests/bug37565.phpt @@ -14,7 +14,7 @@ class Setting extends ReflectionObject { } -Reflection::export(simplexml_load_string('', 'Setting')); +Reflection::export(simplexml_load_string(b'', 'Setting')); Reflection::export(simplexml_load_file('data:,', 'Setting')); diff --git a/ext/simplexml/tests/bug38347.phpt b/ext/simplexml/tests/bug38347.phpt index 1dfad4d60d..feada2f420 100644 --- a/ext/simplexml/tests/bug38347.phpt +++ b/ext/simplexml/tests/bug38347.phpt @@ -13,7 +13,7 @@ function iterate($xml) } } -$xmlstr = "Item 1Item 2"; +$xmlstr = b"Item 1Item 2"; $xml = simplexml_load_string($xmlstr); iterate($xml->unknown); diff --git a/ext/simplexml/tests/bug38354.phpt b/ext/simplexml/tests/bug38354.phpt index d2fcde11c2..e2ebf9fcf9 100644 --- a/ext/simplexml/tests/bug38354.phpt +++ b/ext/simplexml/tests/bug38354.phpt @@ -6,7 +6,7 @@ Bug #38354 (Unwanted reformatting of XML when using AsXML) +b' Item Two ' ); diff --git a/ext/simplexml/tests/profile01.phpt b/ext/simplexml/tests/profile01.phpt index 91b9544f66..6e957b38df 100644 --- a/ext/simplexml/tests/profile01.phpt +++ b/ext/simplexml/tests/profile01.phpt @@ -4,7 +4,7 @@ SimpleXML [profile]: Accessing a simple node --FILE-- +$root = simplexml_load_string(b' Hello diff --git a/ext/simplexml/tests/profile02.phpt b/ext/simplexml/tests/profile02.phpt index 14b5bb86b2..e5bcfded88 100644 --- a/ext/simplexml/tests/profile02.phpt +++ b/ext/simplexml/tests/profile02.phpt @@ -4,7 +4,7 @@ SimpleXML [profile]: Accessing an array of subnodes --FILE-- +$root = simplexml_load_string(b' Hello World diff --git a/ext/simplexml/tests/profile03.phpt b/ext/simplexml/tests/profile03.phpt index 14f1c5fe88..93f54a0ea1 100644 --- a/ext/simplexml/tests/profile03.phpt +++ b/ext/simplexml/tests/profile03.phpt @@ -4,7 +4,7 @@ SimpleXML [profile]: Accessing an attribute --FILE-- +$root = simplexml_load_string(b' diff --git a/ext/simplexml/tests/profile04.phpt b/ext/simplexml/tests/profile04.phpt index 27714e9927..8b88f7483f 100644 --- a/ext/simplexml/tests/profile04.phpt +++ b/ext/simplexml/tests/profile04.phpt @@ -4,7 +4,7 @@ SimpleXML [profile]: Accessing a namespaced element --FILE-- +$root = simplexml_load_string(b' Hello diff --git a/ext/simplexml/tests/profile05.phpt b/ext/simplexml/tests/profile05.phpt index f69622118a..3863937ae6 100644 --- a/ext/simplexml/tests/profile05.phpt +++ b/ext/simplexml/tests/profile05.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing an aliased namespaced element --FILE-- +$root = simplexml_load_string(b' Hello diff --git a/ext/simplexml/tests/profile06.phpt b/ext/simplexml/tests/profile06.phpt index e519fa9d64..788787b9ab 100644 --- a/ext/simplexml/tests/profile06.phpt +++ b/ext/simplexml/tests/profile06.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing a namespaced attribute --FILE-- +$root = simplexml_load_string(b' diff --git a/ext/simplexml/tests/profile07.phpt b/ext/simplexml/tests/profile07.phpt index c8a4269274..cb8e8682fb 100644 --- a/ext/simplexml/tests/profile07.phpt +++ b/ext/simplexml/tests/profile07.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing an aliased namespaced attribute --FILE-- +$root = simplexml_load_string(b' diff --git a/ext/simplexml/tests/profile08.phpt b/ext/simplexml/tests/profile08.phpt index bbb69b75a8..e9fa4232a4 100644 --- a/ext/simplexml/tests/profile08.phpt +++ b/ext/simplexml/tests/profile08.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing a namespaced attribute without a namespace --FILE-- +$root = simplexml_load_string(b' diff --git a/ext/simplexml/tests/profile09.phpt b/ext/simplexml/tests/profile09.phpt index 714572df1e..2fec3afb2e 100644 --- a/ext/simplexml/tests/profile09.phpt +++ b/ext/simplexml/tests/profile09.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing a namespaced element without a namespace --FILE-- +$root = simplexml_load_string(b' Hello diff --git a/ext/simplexml/tests/profile10.phpt b/ext/simplexml/tests/profile10.phpt index 6ef7456c51..95312b02f2 100644 --- a/ext/simplexml/tests/profile10.phpt +++ b/ext/simplexml/tests/profile10.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing two attributes with the same name, but different --FILE-- +$root = simplexml_load_string(b' diff --git a/ext/simplexml/tests/profile11.phpt b/ext/simplexml/tests/profile11.phpt index c2001e9510..adad1b6783 100644 --- a/ext/simplexml/tests/profile11.phpt +++ b/ext/simplexml/tests/profile11.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing two elements with the same name, but different na --FILE-- +$root = simplexml_load_string(b' Hello World diff --git a/ext/simplexml/tests/profile12.phpt b/ext/simplexml/tests/profile12.phpt index d875ce97f4..607aa6aa5d 100755 --- a/ext/simplexml/tests/profile12.phpt +++ b/ext/simplexml/tests/profile12.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing namespaced root and non namespaced children --FILE-- - string(41) "http://schemas.xmlsoap.org/soap/envelope/" + unicode(41) "http://schemas.xmlsoap.org/soap/envelope/" } object(SimpleXMLElement)#%s (0) { } diff --git a/ext/simplexml/tests/profile13.phpt b/ext/simplexml/tests/profile13.phpt index 957c6ec659..bbea002984 100755 --- a/ext/simplexml/tests/profile13.phpt +++ b/ext/simplexml/tests/profile13.phpt @@ -5,7 +5,7 @@ SimpleXML [profile]: Accessing by namespace prefix --FILE--