diff options
Diffstat (limited to 'ext/simplexml')
-rw-r--r-- | ext/simplexml/config.m4 | 2 | ||||
-rw-r--r-- | ext/simplexml/php_simplexml.h | 5 | ||||
-rw-r--r-- | ext/simplexml/php_simplexml_exports.h | 2 | ||||
-rw-r--r-- | ext/simplexml/simplexml.c | 41 | ||||
-rw-r--r-- | ext/simplexml/sxe.c | 4 | ||||
-rw-r--r-- | ext/simplexml/sxe.h | 2 | ||||
-rw-r--r-- | ext/simplexml/tests/001-mb.phpt | 43 | ||||
-rw-r--r-- | ext/simplexml/tests/012.phpt | 5 | ||||
-rw-r--r-- | ext/simplexml/tests/sxe私はガラスを食べられます.xml | 17 |
9 files changed, 91 insertions, 30 deletions
diff --git a/ext/simplexml/config.m4 b/ext/simplexml/config.m4 index b06f5b00f0..ec1b2b2cc5 100644 --- a/ext/simplexml/config.m4 +++ b/ext/simplexml/config.m4 @@ -21,7 +21,7 @@ if test "$PHP_SIMPLEXML" != "no"; then PHP_INSTALL_HEADERS([ext/simplexml/php_simplexml.h ext/simplexml/php_simplexml_exports.h]) PHP_SUBST(SIMPLEXML_SHARED_LIBADD) ], [ - AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) + AC_MSG_ERROR([libxml2 not found. Please check your libxml2 installation.]) ]) PHP_ADD_EXTENSION_DEP(simplexml, libxml) PHP_ADD_EXTENSION_DEP(simplexml, spl, true) diff --git a/ext/simplexml/php_simplexml.h b/ext/simplexml/php_simplexml.h index f5eb7f2f42..5e75a8bed3 100644 --- a/ext/simplexml/php_simplexml.h +++ b/ext/simplexml/php_simplexml.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2017 The PHP Group | + | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -45,9 +45,6 @@ extern zend_module_entry simplexml_module_entry; PHP_MINIT_FUNCTION(simplexml); PHP_MSHUTDOWN_FUNCTION(simplexml); -#ifdef HAVE_SPL -PHP_RINIT_FUNCTION(simplexml); -#endif PHP_MINFO_FUNCTION(simplexml); typedef enum { diff --git a/ext/simplexml/php_simplexml_exports.h b/ext/simplexml/php_simplexml_exports.h index c7c1d249c2..1de8fd9c4a 100644 --- a/ext/simplexml/php_simplexml_exports.h +++ b/ext/simplexml/php_simplexml_exports.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2017 The PHP Group | + | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 0637e06af8..ae067cdcdd 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2017 The PHP Group | + | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -247,8 +247,8 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z if (!member) { if (sxe->iter.type == SXE_ITER_ATTRLIST) { /* This happens when the user did: $sxe[]->foo = $value */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); - return NULL; + zend_throw_error(NULL, "Cannot create unnamed attribute"); + return &EG(uninitialized_zval); } goto long_dim; } else { @@ -284,8 +284,8 @@ long_dim: if (!member && node && node->parent && node->parent->type == XML_DOCUMENT_NODE) { /* This happens when the user did: $sxe[]->foo = $value */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); - return NULL; + zend_throw_error(NULL, "Cannot create unnamed attribute"); + return &EG(uninitialized_zval); } } @@ -330,7 +330,7 @@ long_dim: } if (sxe->iter.type == SXE_ITER_NONE) { if (member && Z_LVAL_P(member) > 0) { - php_error_docref(NULL, E_WARNING, "Cannot add element %s number %pd when only 0 such elements exist", mynode->name, Z_LVAL_P(member)); + php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only 0 such elements exist", mynode->name, Z_LVAL_P(member)); } } else if (member) { node = sxe_get_element_by_offset(sxe, Z_LVAL_P(member), node, &cnt); @@ -341,7 +341,7 @@ long_dim: _node_as_zval(sxe, node, rv, SXE_ITER_NONE, NULL, sxe->iter.nsprefix, sxe->iter.isprefix); } else if (type == BP_VAR_W || type == BP_VAR_RW) { if (member && cnt < Z_LVAL_P(member)) { - php_error_docref(NULL, E_WARNING, "Cannot add element %s number %pd when only %pd such elements exist", mynode->name, Z_LVAL_P(member), cnt); + php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only " ZEND_LONG_FMT " such elements exist", mynode->name, Z_LVAL_P(member), cnt); } node = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, NULL); _node_as_zval(sxe, node, rv, SXE_ITER_NONE, NULL, sxe->iter.nsprefix, sxe->iter.isprefix); @@ -466,7 +466,7 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool * and could also be E_PARSE, but we use this only during parsing * and this is during runtime. */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); + zend_throw_error(NULL, "Cannot create unnamed attribute"); return FAILURE; } goto long_dim; @@ -515,7 +515,7 @@ long_dim: * and could also be E_PARSE, but we use this only during parsing * and this is during runtime. */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); + zend_throw_error(NULL, "Cannot create unnamed attribute"); return FAILURE; } if (attribs && !node && sxe->iter.type == SXE_ITER_ELEMENT) { @@ -588,7 +588,10 @@ long_dim: if (elements) { if (!member || Z_TYPE_P(member) == IS_LONG) { if (node->type == XML_ATTRIBUTE_NODE) { - php_error_docref(NULL, E_ERROR, "Cannot create duplicate attribute"); + zend_throw_error(NULL, "Cannot create duplicate attribute"); + if (new_value) { + zval_ptr_dtor(value); + } return FAILURE; } @@ -596,7 +599,7 @@ long_dim: newnode = node; ++counter; if (member && Z_LVAL_P(member) > 0) { - php_error_docref(NULL, E_WARNING, "Cannot add element %s number %pd when only 0 such elements exist", mynode->name, Z_LVAL_P(member)); + php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only 0 such elements exist", mynode->name, Z_LVAL_P(member)); retval = FAILURE; } } else if (member) { @@ -644,14 +647,14 @@ next_iter: } } else if (!member || Z_TYPE_P(member) == IS_LONG) { if (member && cnt < Z_LVAL_P(member)) { - php_error_docref(NULL, E_WARNING, "Cannot add element %s number %pd when only %pd such elements exist", mynode->name, Z_LVAL_P(member), cnt); + php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only " ZEND_LONG_FMT " such elements exist", mynode->name, Z_LVAL_P(member), cnt); retval = FAILURE; } newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value ? (xmlChar *)Z_STRVAL_P(value) : NULL); } } else if (attribs) { if (Z_TYPE_P(member) == IS_LONG) { - php_error_docref(NULL, E_WARNING, "Cannot change attribute number %pd when only %d attributes exist", Z_LVAL_P(member), nodendx); + php_error_docref(NULL, E_WARNING, "Cannot change attribute number " ZEND_LONG_FMT " when only %d attributes exist", Z_LVAL_P(member), nodendx); retval = FAILURE; } else { newnode = (xmlNodePtr)xmlNewProp(node, (xmlChar *)Z_STRVAL_P(member), value ? (xmlChar *)Z_STRVAL_P(value) : NULL); @@ -713,7 +716,6 @@ static zval *sxe_property_get_adr(zval *object, zval *member, int fetch_type, vo _node_as_zval(sxe, node, &ret, type, name, sxe->iter.nsprefix, sxe->iter.isprefix); - sxe = Z_SXEOBJ_P(&ret); if (!Z_ISUNDEF(sxe->tmp)) { zval_ptr_dtor(&sxe->tmp); } @@ -1988,12 +1990,8 @@ static int sxe_count_elements(zval *object, zend_long *count) /* {{{ */ zval rv; zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv); if (!Z_ISUNDEF(rv)) { - if (!Z_ISUNDEF(intern->tmp)) { - zval_ptr_dtor(&intern->tmp); - } - ZVAL_LONG(&intern->tmp, zval_get_long(&rv)); + *count = zval_get_long(&rv); zval_ptr_dtor(&rv); - *count = Z_LVAL(intern->tmp); return SUCCESS; } return FAILURE; @@ -2053,7 +2051,9 @@ static zend_object_handlers sxe_object_handlers = { /* {{{ */ sxe_count_elements, sxe_get_debug_info, NULL, - sxe_get_gc + sxe_get_gc, + NULL, + NULL }; /* }}} */ @@ -2355,6 +2355,7 @@ zend_object_iterator_funcs php_sxe_iterator_funcs = { /* {{{ */ php_sxe_iterator_current_key, php_sxe_iterator_move_forward, php_sxe_iterator_rewind, + NULL }; /* }}} */ diff --git a/ext/simplexml/sxe.c b/ext/simplexml/sxe.c index 30b4526910..701034d0b3 100644 --- a/ext/simplexml/sxe.c +++ b/ext/simplexml/sxe.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2017 The PHP Group | + | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -189,7 +189,7 @@ static const zend_function_entry funcs_SimpleXMLIterator[] = { PHP_ME(ce_SimpleXMLIterator, next, arginfo_simplexmliterator__void, ZEND_ACC_PUBLIC) PHP_ME(ce_SimpleXMLIterator, hasChildren, arginfo_simplexmliterator__void, ZEND_ACC_PUBLIC) PHP_ME(ce_SimpleXMLIterator, getChildren, arginfo_simplexmliterator__void, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} + PHP_FE_END }; /* }}} */ diff --git a/ext/simplexml/sxe.h b/ext/simplexml/sxe.h index ed5fa02ba3..ea645e9710 100644 --- a/ext/simplexml/sxe.h +++ b/ext/simplexml/sxe.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2017 The PHP Group | + | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/simplexml/tests/001-mb.phpt b/ext/simplexml/tests/001-mb.phpt new file mode 100644 index 0000000000..ee4d6f085f --- /dev/null +++ b/ext/simplexml/tests/001-mb.phpt @@ -0,0 +1,43 @@ +--TEST-- +SimpleXML: Simple document +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +var_dump(simplexml_load_file(dirname(__FILE__).'/sxe私はガラスを食べられます.xml')); + +?> +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (1) { + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt index 2fc9bec41e..abbb10b8d3 100644 --- a/ext/simplexml/tests/012.phpt +++ b/ext/simplexml/tests/012.phpt @@ -37,4 +37,7 @@ Warning: main(): Cannot write or create unnamed attribute in %s012.php on line % <?xml version="1.0" encoding="ISO-8859-1"?> <foo attr="new value"/> -Fatal error: main(): Cannot create unnamed attribute in %s012.php on line %d +Fatal error: Uncaught Error: Cannot create unnamed attribute in %s012.php:%d +Stack trace: +#0 {main} + thrown in %s012.php on line %d diff --git a/ext/simplexml/tests/sxe私はガラスを食べられます.xml b/ext/simplexml/tests/sxe私はガラスを食べられます.xml new file mode 100644 index 0000000000..909b4e652c --- /dev/null +++ b/ext/simplexml/tests/sxe私はガラスを食べられます.xml @@ -0,0 +1,17 @@ +<?xml version='1.0'?> +<!DOCTYPE sxe SYSTEM "notfound.dtd" [ +<!ENTITY % incent SYSTEM "sxe.ent"> +%incent; +]> +<sxe id="elem1"> + <elem1 attr1='first'> + <!-- comment --> + <elem2> + <elem3> + <elem4> + <?test processing instruction ?> + </elem4> + </elem3> + </elem2> + </elem1> +</sxe>
\ No newline at end of file |