diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:34:37 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:34:37 -0400 |
| commit | 10f5b47dc7c1cf2b9a00991629f43652710322d3 (patch) | |
| tree | 3b727a16f652b8042d573e90f003868ffb3b56c7 /ext/xml | |
| parent | 0e920280a2e04b110827bb766b9f29e3d581c4ee (diff) | |
| download | php-10f5b47dc7c1cf2b9a00991629f43652710322d3.tar.gz | |
Imported Upstream version 5.0.5upstream/5.0.5
Diffstat (limited to 'ext/xml')
| -rw-r--r-- | ext/xml/config.m4 | 28 | ||||
| -rw-r--r-- | ext/xml/php_xml.h | 3 | ||||
| -rw-r--r-- | ext/xml/tests/bug32001.phpt | 13 | ||||
| -rw-r--r-- | ext/xml/xml.c | 13 |
4 files changed, 40 insertions, 17 deletions
diff --git a/ext/xml/config.m4 b/ext/xml/config.m4 index 7c7e8f984..7d288042d 100644 --- a/ext/xml/config.m4 +++ b/ext/xml/config.m4 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.48 2003/11/12 23:42:36 sniper Exp $ +dnl $Id: config.m4,v 1.48.2.1 2005/04/27 13:13:38 sniper Exp $ dnl PHP_ARG_ENABLE(xml,whether to enable XML support, @@ -13,31 +13,37 @@ fi PHP_ARG_WITH(libexpat-dir, libexpat install dir, [ --with-libexpat-dir=DIR XML: libexpat install prefix (deprecated)], no, no) -if test "$PHP_XML" != "no" && test "$PHP_LIBXML" != "no" -o "$PHP_LIBEXPAT_DIR" != "no"; then +if test "$PHP_XML" != "no"; then + dnl - dnl Default to libxml2. + dnl Default to libxml2 if --with-libexpat-dir is not used. dnl - PHP_SETUP_LIBXML(XML_SHARED_LIBADD, [ - xml_extra_sources="compat.c" - ], [ - if test "$PHP_LIBEXPAT_DIR" = "no"; then - AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>]) + if test "$PHP_LIBEXPAT_DIR" = "no"; then + + if test "$PHP_LIBXML" = "no"; then + AC_MSG_ERROR([XML extension requires LIBXML extension, add --enable-libxml]) fi - ]) + + PHP_SETUP_LIBXML(XML_SHARED_LIBADD, [ + xml_extra_sources="compat.c" + ], [ + AC_MSG_ERROR([xml2-config not found. Use --with-libxml-dir=<DIR>]) + ]) + fi dnl dnl Check for expat only if --with-libexpat-dir is used. dnl if test "$PHP_LIBEXPAT_DIR" != "no"; then for i in $PHP_XML $PHP_LIBEXPAT_DIR; do - if test -f "$i/lib/libexpat.a" -o -f "$i/lib/libexpat.$SHLIB_SUFFIX_NAME"; then + if test -f "$i/lib/libexpat.a" || test -f "$i/lib/libexpat.$SHLIB_SUFFIX_NAME"; then EXPAT_DIR=$i break fi done if test -z "$EXPAT_DIR"; then - AC_MSG_ERROR(not found. Please reinstall the expat distribution.) + AC_MSG_ERROR([not found. Please reinstall the expat distribution.]) fi PHP_ADD_INCLUDE($EXPAT_DIR/include) diff --git a/ext/xml/php_xml.h b/ext/xml/php_xml.h index 8f0f97544..e149bdb72 100644 --- a/ext/xml/php_xml.h +++ b/ext/xml/php_xml.h @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_xml.h,v 1.26 2004/01/08 17:32:59 sniper Exp $ */ +/* $Id: php_xml.h,v 1.26.2.1 2005/04/28 12:17:18 rrichards Exp $ */ #ifndef PHP_XML_H #define PHP_XML_H @@ -90,6 +90,7 @@ typedef struct { char **ltags; int lastwasopen; int skipwhite; + int isparsing; XML_Char *baseURI; } xml_parser; diff --git a/ext/xml/tests/bug32001.phpt b/ext/xml/tests/bug32001.phpt index 375ceafed..57b0d130c 100644 --- a/ext/xml/tests/bug32001.phpt +++ b/ext/xml/tests/bug32001.phpt @@ -1,5 +1,8 @@ --TEST-- Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect) +--SKIPIF-- +<?php # vim:ft=php +if (!extension_loaded("iconv")) print "skip"; --FILE-- <?php class testcase { @@ -151,10 +154,12 @@ $suite = array( new testcase("GB2312", 1), ); -preg_match("/^libxml2 Version.*\$/im", `$_ENV[TEST_PHP_EXECUTABLE] -i`, $match); - -echo $match[0], "\n"; - +if (XML_SAX_IMPL == 'libxml') { + preg_match("/^libxml2 Version.*\$/im", `$_ENV[TEST_PHP_EXECUTABLE] -i`, $match); + echo $match[0], "\n"; +} else { + echo "libxml2 Version => NONE\n"; +} foreach ($suite as $testcase) { $testcase->run(); diff --git a/ext/xml/xml.c b/ext/xml/xml.c index 76702089c..007a5b93c 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xml.c,v 1.151.2.3 2005/03/11 01:14:29 helly Exp $ */ +/* $Id: xml.c,v 1.151.2.4 2005/04/28 12:17:18 rrichards Exp $ */ #define IS_EXT_MODULE @@ -1076,6 +1076,8 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp parser->target_encoding = encoding; parser->case_folding = 1; parser->object = NULL; + parser->isparsing = 0; + XML_SetUserData(parser->parser, parser); ZEND_REGISTER_RESOURCE(return_value, parser,le_xml_parser); @@ -1334,7 +1336,9 @@ PHP_FUNCTION(xml_parse) isFinal = 0; } + parser->isparsing = 1; ret = XML_Parse(parser->parser, Z_STRVAL_PP(data), Z_STRLEN_PP(data), isFinal); + parser->isparsing = 0; RETVAL_LONG(ret); } @@ -1373,7 +1377,9 @@ PHP_FUNCTION(xml_parse_into_struct) XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler); XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler); + parser->isparsing = 1; ret = XML_Parse(parser->parser, Z_STRVAL_PP(data), Z_STRLEN_PP(data), 1); + parser->isparsing = 0; RETVAL_LONG(ret); } @@ -1474,6 +1480,11 @@ PHP_FUNCTION(xml_parser_free) ZEND_FETCH_RESOURCE(parser,xml_parser *, pind, -1, "XML Parser", le_xml_parser); + if (parser->isparsing == 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parser cannot be freed while it is parsing."); + RETURN_FALSE; + } + if (zend_list_delete(parser->index) == FAILURE) { RETURN_FALSE; } |
