chregu Fri Aug 13 08:32:55 2004 EDT Modified files: /php-src NEWS /php-src/ext/dom document.c dom_properties.h php_dom.c xml_common.h Log: Added DomDocument->recover property for parsing not well-formed XML Documents. http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1790&r2=1.1791&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.1790 php-src/NEWS:1.1791 --- php-src/NEWS:1.1790 Tue Aug 10 13:39:59 2004 +++ php-src/NEWS Fri Aug 13 08:32:55 2004 @@ -24,6 +24,8 @@ . mysqli->client_info property (Georg) . inet_pton() (Sara) . inet_ntop() (Sara) +- Added DomDocument->recover property for parsing not well-formed + XML Documents. (Christian) - Added Cursor support for MySQL 5.0.x in mysqli (Georg) - Added proxy support to ftp wrapper via http. (Sara) - Added MDTM support to ftp_url_stat. (Sara) http://cvs.php.net/diff.php/php-src/ext/dom/document.c?r1=1.56&r2=1.57&ty=u Index: php-src/ext/dom/document.c diff -u php-src/ext/dom/document.c:1.56 php-src/ext/dom/document.c:1.57 --- php-src/ext/dom/document.c:1.56 Sun Jul 18 09:16:15 2004 +++ php-src/ext/dom/document.c Fri Aug 13 08:32:55 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: document.c,v 1.56 2004/07/18 13:16:15 rrichards Exp $ */ +/* $Id: document.c,v 1.57 2004/08/13 12:32:55 chregu Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -614,6 +614,48 @@ } /* }}} */ +/* {{{ proto recover boolean +readonly=no +*/ +int dom_document_recover_read(dom_object *obj, zval **retval TSRMLS_DC) +{ + dom_doc_props *doc_prop; + + ALLOC_ZVAL(*retval); + if (obj->document) { + doc_prop = dom_get_doc_props(obj->document); + ZVAL_BOOL(*retval, doc_prop->recover); + } else { + ZVAL_FALSE(*retval); + } + return SUCCESS; +} + +int dom_document_recover_write(dom_object *obj, zval *newval TSRMLS_DC) +{ + zval value_copy; + dom_doc_props *doc_prop; + + if(newval->refcount > 1) { + value_copy = *newval; + zval_copy_ctor(&value_copy); + newval = &value_copy; + } + convert_to_boolean(newval); + + if (obj->document) { + doc_prop = dom_get_doc_props(obj->document); + doc_prop->recover = Z_LVAL_P(newval); + } + + if (newval == &value_copy) { + zval_dtor(newval); + } + + return SUCCESS; +} +/* }}} */ + /* {{{ proto substituteEntities boolean readonly=no @@ -1392,7 +1434,7 @@ dom_doc_props *doc_props; dom_object *intern; php_libxml_ref_obj *document = NULL; - int validate, resolve_externals, keep_blanks, substitute_ent; + int validate, recover, resolve_externals, keep_blanks, substitute_ent; int resolved_path_len; char *directory=NULL, resolved_path[MAXPATHLEN]; @@ -1406,6 +1448,7 @@ resolve_externals = doc_props->resolveexternals; keep_blanks = doc_props->preservewhitespace; substitute_ent = doc_props->substituteentities; + recover = doc_props->recover; if (document == NULL) { efree(doc_props); @@ -1455,7 +1498,7 @@ } } - ctxt->recovery = 0; + ctxt->recovery = recover; ctxt->validate = validate; ctxt->loadsubset = (resolve_externals * XML_COMPLETE_ATTRS); ctxt->replaceEntities = substitute_ent; @@ -1470,7 +1513,7 @@ xmlParseDocument(ctxt); - if (ctxt->wellFormed) { + if (ctxt->wellFormed || recover) { ret = ctxt->myDoc; /* If loading from memory, set the base reference uri for the document */ if (ret->URL == NULL && ctxt->directory != NULL) { http://cvs.php.net/diff.php/php-src/ext/dom/dom_properties.h?r1=1.5&r2=1.6&ty=u Index: php-src/ext/dom/dom_properties.h diff -u php-src/ext/dom/dom_properties.h:1.5 php-src/ext/dom/dom_properties.h:1.6 --- php-src/ext/dom/dom_properties.h:1.5 Thu Jan 8 12:32:03 2004 +++ php-src/ext/dom/dom_properties.h Fri Aug 13 08:32:55 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dom_properties.h,v 1.5 2004/01/08 17:32:03 sniper Exp $ */ +/* $Id: dom_properties.h,v 1.6 2004/08/13 12:32:55 chregu Exp $ */ #ifndef DOM_PROPERTIES_H #define DOM_PROPERTIES_H @@ -59,6 +59,8 @@ int dom_document_resolve_externals_write(dom_object *obj, zval *newval TSRMLS_DC); int dom_document_preserve_whitespace_read(dom_object *obj, zval **retval TSRMLS_DC); int dom_document_preserve_whitespace_write(dom_object *obj, zval *newval TSRMLS_DC); +int dom_document_recover_read(dom_object *obj, zval **retval TSRMLS_DC); +int dom_document_recover_write(dom_object *obj, zval *newval TSRMLS_DC); int dom_document_substitue_entities_read(dom_object *obj, zval **retval TSRMLS_DC); int dom_document_substitue_entities_write(dom_object *obj, zval *newval TSRMLS_DC); http://cvs.php.net/diff.php/php-src/ext/dom/php_dom.c?r1=1.61&r2=1.62&ty=u Index: php-src/ext/dom/php_dom.c diff -u php-src/ext/dom/php_dom.c:1.61 php-src/ext/dom/php_dom.c:1.62 --- php-src/ext/dom/php_dom.c:1.61 Sun Jul 25 14:50:24 2004 +++ php-src/ext/dom/php_dom.c Fri Aug 13 08:32:55 2004 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_dom.c,v 1.61 2004/07/25 18:50:24 helly Exp $ */ +/* $Id: php_dom.c,v 1.62 2004/08/13 12:32:55 chregu Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -126,6 +126,7 @@ doc_props->preservewhitespace = 1; doc_props->substituteentities = 0; doc_props->stricterror = 1; + doc_props->recover = 0; if (document) { document->doc_props = doc_props; } @@ -462,6 +463,7 @@ dom_register_prop_handler(&dom_document_prop_handlers, "validateOnParse", dom_document_validate_on_parse_read, dom_document_validate_on_parse_write TSRMLS_CC); dom_register_prop_handler(&dom_document_prop_handlers, "resolveExternals", dom_document_resolve_externals_read, dom_document_resolve_externals_write TSRMLS_CC); dom_register_prop_handler(&dom_document_prop_handlers, "preserveWhiteSpace", dom_document_preserve_whitespace_read, dom_document_preserve_whitespace_write TSRMLS_CC); + dom_register_prop_handler(&dom_document_prop_handlers, "recover", dom_document_recover_read, dom_document_recover_write TSRMLS_CC); dom_register_prop_handler(&dom_document_prop_handlers, "substituteEntities", dom_document_substitue_entities_read, dom_document_substitue_entities_write TSRMLS_CC); zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); http://cvs.php.net/diff.php/php-src/ext/dom/xml_common.h?r1=1.19&r2=1.20&ty=u Index: php-src/ext/dom/xml_common.h diff -u php-src/ext/dom/xml_common.h:1.19 php-src/ext/dom/xml_common.h:1.20 --- php-src/ext/dom/xml_common.h:1.19 Thu Jan 8 12:32:03 2004 +++ php-src/ext/dom/xml_common.h Fri Aug 13 08:32:55 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xml_common.h,v 1.19 2004/01/08 17:32:03 sniper Exp $ */ +/* $Id: xml_common.h,v 1.20 2004/08/13 12:32:55 chregu Exp $ */ #ifndef PHP_XML_COMMON_H #define PHP_XML_COMMON_H @@ -31,6 +31,7 @@ int preservewhitespace; int substituteentities; int stricterror; + int recover; } dom_doc_props; typedef dom_doc_props *dom_doc_propsptr;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php