summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/dom/TODO16
-rw-r--r--ext/dom/attr.c14
-rw-r--r--ext/dom/cdatasection.c7
-rw-r--r--ext/dom/comment.c7
-rw-r--r--ext/dom/document.c10
-rw-r--r--ext/dom/documentfragment.c7
-rw-r--r--ext/dom/dom_fe.h14
-rw-r--r--ext/dom/element.c16
-rw-r--r--ext/dom/entityreference.c9
-rw-r--r--ext/dom/php_dom.c3
-rw-r--r--ext/dom/processinginstruction.c9
-rw-r--r--ext/dom/text.c7
-rw-r--r--ext/dom/xpath.c4
13 files changed, 85 insertions, 38 deletions
diff --git a/ext/dom/TODO b/ext/dom/TODO
index f6b7fe2e61..52afb18216 100644
--- a/ext/dom/TODO
+++ b/ext/dom/TODO
@@ -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)
diff --git a/ext/dom/attr.c b/ext/dom/attr.c
index aa9f158e56..b574b1abec 100644
--- a/ext/dom/attr.c
+++ b/ext/dom/attr.c
@@ -52,23 +52,29 @@ PHP_METHOD(domattr, __construct)
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;
diff --git a/ext/dom/cdatasection.c b/ext/dom/cdatasection.c
index 0dc18a9358..fde9ea5670 100644
--- a/ext/dom/cdatasection.c
+++ b/ext/dom/cdatasection.c
@@ -50,14 +50,19 @@ PHP_METHOD(domcdatasection, __construct)
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) {
diff --git a/ext/dom/comment.c b/ext/dom/comment.c
index a5d3b9c55b..be921a8fad 100644
--- a/ext/dom/comment.c
+++ b/ext/dom/comment.c
@@ -50,14 +50,19 @@ PHP_METHOD(domcomment, __construct)
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) {
diff --git a/ext/dom/document.c b/ext/dom/document.c
index 427e711447..5dbfaa8f3c 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -740,7 +740,7 @@ int dom_document_config_read(dom_object *obj, zval **retval TSRMLS_DC)
-/* {{{ 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 @@ PHP_METHOD(domdocument, __construct)
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);
diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c
index 3b565c4efd..d47fd725e6 100644
--- a/ext/dom/documentfragment.c
+++ b/ext/dom/documentfragment.c
@@ -48,14 +48,19 @@ PHP_METHOD(domdocumentfragment, __construct)
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) {
diff --git a/ext/dom/dom_fe.h b/ext/dom/dom_fe.h
index 511708a0a1..3d860a54be 100644
--- a/ext/dom/dom_fe.h
+++ b/ext/dom/dom_fe.h
@@ -54,6 +54,8 @@ extern zend_function_entry php_dom_xpath_class_functions[];
/* 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 @@ typedef enum {
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;
diff --git a/ext/dom/element.c b/ext/dom/element.c
index 944c9c946e..c817a3c01e 100644
--- a/ext/dom/element.c
+++ b/ext/dom/element.c
@@ -68,15 +68,19 @@ PHP_METHOD(domelement, __construct)
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 @@ PHP_METHOD(domelement, __construct)
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);
diff --git a/ext/dom/entityreference.c b/ext/dom/entityreference.c
index b44da01a8e..4ac617d277 100644
--- a/ext/dom/entityreference.c
+++ b/ext/dom/entityreference.c
@@ -50,19 +50,24 @@ PHP_METHOD(domentityreference, __construct)
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) {
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index d11e2d67f8..8e60238af3 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -624,7 +624,8 @@ PHP_MINIT_FUNCTION(dom)
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);
diff --git a/ext/dom/processinginstruction.c b/ext/dom/processinginstruction.c
index 70cf83035c..b0b4cb275b 100644
--- a/ext/dom/processinginstruction.c
+++ b/ext/dom/processinginstruction.c
@@ -50,19 +50,24 @@ PHP_METHOD(domprocessinginstruction, __construct)
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) {
diff --git a/ext/dom/text.c b/ext/dom/text.c
index 78fd7feafe..e3c4f05a3c 100644
--- a/ext/dom/text.c
+++ b/ext/dom/text.c
@@ -53,14 +53,19 @@ PHP_METHOD(domtext, __construct)
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) {
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index e4e22c0a41..9f0f59cc0d 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -49,14 +49,18 @@ PHP_METHOD(domxpath, __construct)
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;
}