rrichards Sun May 16 06:30:18 2004 EDT
Modified files:
/php-src/ext/dom TODO attr.c cdatasection.c comment.c document.c
documentfragment.c dom_fe.h element.c
entityreference.c php_dom.c
processinginstruction.c text.c xpath.c
Log:
constructors throw DOMException
add DOM_PHP_ERR DomException code
validate tagnames in constructors
use C style comments
update TODO
http://cvs.php.net/diff.php/php-src/ext/dom/TODO?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/dom/TODO
diff -u php-src/ext/dom/TODO:1.1 php-src/ext/dom/TODO:1.2
--- php-src/ext/dom/TODO:1.1 Thu Jun 5 13:06:52 2003
+++ php-src/ext/dom/TODO Sun May 16 06:30:16 2004
@@ -1,12 +1,4 @@
-1) Change _node_list_pointer to something faster than just a linked list.
- Currently there to test that unlinked node tracking works
-2) Possible create new object type for documents as these are the only types which
need to track nodes
- - Would also require its own dtor functionality
-3) Define correct behavior. When certain types of nodes are destroyed,
- do we unlink children (if referenced) or just destroy them. (Element/Attribute
nodes)
-4) Find out where XPath goes (this extension or its own)
-5) What DOM object types are really needed (i.e. not currently using DOMString)
-6) Determine how to handle non speced functionality.
- i.e validation (add method or implement as property for processing)
-
-
+For 5.1
+1) enhance XPath functionality
+2) look at auto encoding support for in/output
+3) What DOM object types are really needed (i.e. not currently using DOMString)
http://cvs.php.net/diff.php/php-src/ext/dom/attr.c?r1=1.13&r2=1.14&ty=u
Index: php-src/ext/dom/attr.c
diff -u php-src/ext/dom/attr.c:1.13 php-src/ext/dom/attr.c:1.14
--- php-src/ext/dom/attr.c:1.13 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/attr.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: attr.c,v 1.13 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: attr.c,v 1.14 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -52,23 +52,29 @@
xmlNodePtr oldnode = NULL;
dom_object *intern;
char *name, *value = NULL;
- int name_len, value_len;
+ int name_len, value_len, name_valid;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s",
&id, dom_attr_class_entry, &name, &name_len, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
- if (name_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attribute name is
required");
+ name_valid = xmlValidateName((xmlChar *) name, 0);
+ if (name_valid != 0) {
+ php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
nodep = xmlNewProp(NULL, (xmlChar *) name, value);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
if (intern != NULL) {
oldnode = (xmlNodePtr)intern->ptr;
http://cvs.php.net/diff.php/php-src/ext/dom/cdatasection.c?r1=1.8&r2=1.9&ty=u
Index: php-src/ext/dom/cdatasection.c
diff -u php-src/ext/dom/cdatasection.c:1.8 php-src/ext/dom/cdatasection.c:1.9
--- php-src/ext/dom/cdatasection.c:1.8 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/cdatasection.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cdatasection.c,v 1.8 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: cdatasection.c,v 1.9 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -50,14 +50,19 @@
char *value = NULL;
int value_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os",
&id, dom_cdatasection_class_entry, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
nodep = xmlNewCDataBlock(NULL, (xmlChar *) value, value_len);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
http://cvs.php.net/diff.php/php-src/ext/dom/comment.c?r1=1.8&r2=1.9&ty=u
Index: php-src/ext/dom/comment.c
diff -u php-src/ext/dom/comment.c:1.8 php-src/ext/dom/comment.c:1.9
--- php-src/ext/dom/comment.c:1.8 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/comment.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: comment.c,v 1.8 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: comment.c,v 1.9 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -50,14 +50,19 @@
char *value = NULL;
int value_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s",
&id, dom_comment_class_entry, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
nodep = xmlNewComment((xmlChar *) value);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
http://cvs.php.net/diff.php/php-src/ext/dom/document.c?r1=1.51&r2=1.52&ty=u
Index: php-src/ext/dom/document.c
diff -u php-src/ext/dom/document.c:1.51 php-src/ext/dom/document.c:1.52
--- php-src/ext/dom/document.c:1.51 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/document.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: document.c,v 1.51 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: document.c,v 1.52 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -740,7 +740,7 @@
-/* {{{ proto domelement dom_document_create_element(string tagName);
+/* {{{ proto domelement dom_document_create_element(string tagName [, string value]);
URL:
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-2141741547
Since:
*/
@@ -1296,13 +1296,19 @@
char *encoding, *version = NULL;
int encoding_len = 0, version_len = 0, refcount;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ss",
&id, dom_document_class_entry, &version, &version_len, &encoding, &encoding_len) ==
FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
docp = xmlNewDoc(version);
- if (!docp)
+
+ if (!docp) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
if (encoding_len > 0) {
docp->encoding = (const xmlChar*)xmlStrdup(encoding);
http://cvs.php.net/diff.php/php-src/ext/dom/documentfragment.c?r1=1.9&r2=1.10&ty=u
Index: php-src/ext/dom/documentfragment.c
diff -u php-src/ext/dom/documentfragment.c:1.9 php-src/ext/dom/documentfragment.c:1.10
--- php-src/ext/dom/documentfragment.c:1.9 Thu Apr 29 08:59:22 2004
+++ php-src/ext/dom/documentfragment.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: documentfragment.c,v 1.9 2004/04/29 12:59:22 iliaa Exp $ */
+/* $Id: documentfragment.c,v 1.10 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -48,14 +48,19 @@
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&id, dom_documentfragment_class_entry) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
nodep = xmlNewDocFragment(NULL);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
http://cvs.php.net/diff.php/php-src/ext/dom/dom_fe.h?r1=1.10&r2=1.11&ty=u
Index: php-src/ext/dom/dom_fe.h
diff -u php-src/ext/dom/dom_fe.h:1.10 php-src/ext/dom/dom_fe.h:1.11
--- php-src/ext/dom/dom_fe.h:1.10 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/dom_fe.h Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dom_fe.h,v 1.10 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: dom_fe.h,v 1.11 2004/05/16 10:30:16 rrichards Exp $ */
#ifndef DOM_FE_H
#define DOM_FE_H
@@ -54,6 +54,8 @@
/* domexception errors */
typedef enum {
+/* PHP_ERR is non-spec code for PHP errors: */
+ PHP_ERR = 0,
INDEX_SIZE_ERR = 1,
DOMSTRING_SIZE_ERR = 2,
HIERARCHY_REQUEST_ERR = 3,
@@ -64,17 +66,17 @@
NOT_FOUND_ERR = 8,
NOT_SUPPORTED_ERR = 9,
INUSE_ATTRIBUTE_ERR = 10,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
INVALID_STATE_ERR = 11,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
SYNTAX_ERR = 12,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
INVALID_MODIFICATION_ERR = 13,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
NAMESPACE_ERR = 14,
-// Introduced in DOM Level 2:
+/* Introduced in DOM Level 2: */
INVALID_ACCESS_ERR = 15,
-// Introduced in DOM Level 3:
+/* Introduced in DOM Level 3: */
VALIDATION_ERR = 16
} dom_exception_code;
http://cvs.php.net/diff.php/php-src/ext/dom/element.c?r1=1.27&r2=1.28&ty=u
Index: php-src/ext/dom/element.c
diff -u php-src/ext/dom/element.c:1.27 php-src/ext/dom/element.c:1.28
--- php-src/ext/dom/element.c:1.27 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/element.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: element.c,v 1.27 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: element.c,v 1.28 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -68,15 +68,19 @@
char *name, *value = NULL, *uri = NULL;
char *localname = NULL, *prefix = NULL;
int errorcode = 0, uri_len = 0;
- int name_len, value_len = 0;
+ int name_len, value_len = 0, name_valid;
xmlNsPtr nsptr = NULL;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
"Os|s!s", &id, dom_element_class_entry, &name, &name_len, &value, &value_len, &uri,
&uri_len) == FAILURE) {
+ php_std_error_handling();
return;
}
- if (name_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Element name is
required");
+ php_std_error_handling();
+ name_valid = xmlValidateName((xmlChar *) name, 0);
+ if (name_valid != 0) {
+ php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
@@ -98,15 +102,17 @@
if (nodep != NULL) {
xmlFree(nodep);
}
- php_dom_throw_error(errorcode, 0 TSRMLS_CC);
+ php_dom_throw_error(errorcode, 1 TSRMLS_CC);
RETURN_FALSE;
}
} else {
nodep = xmlNewNode(NULL, (xmlChar *) name);
}
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
if (value_len > 0) {
xmlNodeSetContentLen(nodep, value, value_len);
http://cvs.php.net/diff.php/php-src/ext/dom/entityreference.c?r1=1.8&r2=1.9&ty=u
Index: php-src/ext/dom/entityreference.c
diff -u php-src/ext/dom/entityreference.c:1.8 php-src/ext/dom/entityreference.c:1.9
--- php-src/ext/dom/entityreference.c:1.8 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/entityreference.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: entityreference.c,v 1.8 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: entityreference.c,v 1.9 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -50,19 +50,24 @@
char *name;
int name_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os",
&id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
if (name_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Entity Reference name is
required");
+ php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
node = xmlNewReference(NULL, name);
- if (!node)
+ if (!node) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
http://cvs.php.net/diff.php/php-src/ext/dom/php_dom.c?r1=1.57&r2=1.58&ty=u
Index: php-src/ext/dom/php_dom.c
diff -u php-src/ext/dom/php_dom.c:1.57 php-src/ext/dom/php_dom.c:1.58
--- php-src/ext/dom/php_dom.c:1.57 Mon Mar 29 14:28:49 2004
+++ php-src/ext/dom/php_dom.c Sun May 16 06:30:16 2004
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_dom.c,v 1.57 2004/03/29 19:28:49 helly Exp $ */
+/* $Id: php_dom.c,v 1.58 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -624,7 +624,8 @@
REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ENUMERATION",
XML_ATTRIBUTE_ENUMERATION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_NOTATION",
XML_ATTRIBUTE_NOTATION, CONST_CS | CONST_PERSISTENT);
- /* domException Codes */
+ /* DOMException Codes */
+ REGISTER_LONG_CONSTANT("DOM_PHP_ERR", PHP_ERR,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DOM_INDEX_SIZE_ERR", INDEX_SIZE_ERR,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DOMSTRING_SIZE_ERR", DOMSTRING_SIZE_ERR,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DOM_HIERARCHY_REQUEST_ERR", HIERARCHY_REQUEST_ERR,
CONST_CS | CONST_PERSISTENT);
http://cvs.php.net/diff.php/php-src/ext/dom/processinginstruction.c?r1=1.12&r2=1.13&ty=u
Index: php-src/ext/dom/processinginstruction.c
diff -u php-src/ext/dom/processinginstruction.c:1.12
php-src/ext/dom/processinginstruction.c:1.13
--- php-src/ext/dom/processinginstruction.c:1.12 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/processinginstruction.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: processinginstruction.c,v 1.12 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: processinginstruction.c,v 1.13 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -50,19 +50,24 @@
char *name, *value = NULL;
int name_len, value_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s",
&id, dom_processinginstruction_class_entry, &name, &name_len, &value, &value_len) ==
FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
if (name_len == 0) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "PI name is required");
+ php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
nodep = xmlNewPI((xmlChar *) name, (xmlChar *) value);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
http://cvs.php.net/diff.php/php-src/ext/dom/text.c?r1=1.18&r2=1.19&ty=u
Index: php-src/ext/dom/text.c
diff -u php-src/ext/dom/text.c:1.18 php-src/ext/dom/text.c:1.19
--- php-src/ext/dom/text.c:1.18 Wed Mar 31 12:18:59 2004
+++ php-src/ext/dom/text.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: text.c,v 1.18 2004/03/31 17:18:59 rrichards Exp $ */
+/* $Id: text.c,v 1.19 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -53,14 +53,19 @@
char *value = NULL;
int value_len;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|s",
&id, dom_text_class_entry, &value, &value_len) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
nodep = xmlNewText((xmlChar *) value);
- if (!nodep)
+ if (!nodep) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
+ }
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
http://cvs.php.net/diff.php/php-src/ext/dom/xpath.c?r1=1.20&r2=1.21&ty=u
Index: php-src/ext/dom/xpath.c
diff -u php-src/ext/dom/xpath.c:1.20 php-src/ext/dom/xpath.c:1.21
--- php-src/ext/dom/xpath.c:1.20 Tue Apr 6 14:26:19 2004
+++ php-src/ext/dom/xpath.c Sun May 16 06:30:16 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xpath.c,v 1.20 2004/04/06 18:26:19 rrichards Exp $ */
+/* $Id: xpath.c,v 1.21 2004/05/16 10:30:16 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -49,14 +49,18 @@
dom_object *docobj, *intern;
xmlXPathContextPtr ctx, oldctx;
+ php_set_error_handling(EH_THROW, dom_domexception_class_entry TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO",
&id, dom_xpath_class_entry, &doc, dom_document_class_entry) == FAILURE) {
+ php_std_error_handling();
return;
}
+ php_std_error_handling();
DOM_GET_OBJ(docp, doc, xmlDocPtr, docobj);
ctx = xmlXPathNewContext(docp);
if (ctx == NULL) {
+ php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php