Apologies for further ignorance, the attachment seems to be dropped by
news server? It is:
--- ext/xml/xml.c.orig 2004-12-09 03:10:00.000000000 -0500
+++ ext/xml/xml.c 2004-12-09 03:28:24.000000000 -0500
@@ -396,6 +396,13 @@
zval_ptr_dtor(handler);
}
+ /* if FALSE or empty string, disable the handler */
+ if (((Z_TYPE_PP(data) == IS_STRING) && (Z_STRLEN_PP(data) == 0)) ||
+ ((Z_TYPE_PP(data) == IS_BOOL) && !Z_BVAL_PP(data))) {
+ *handler = NULL;
+ return;
+ }
+
/* IS_ARRAY might indicate that we're using array($obj, 'method')
syntax */
if (Z_TYPE_PP(data) != IS_ARRAY) {
convert_to_string_ex(data);
Original email follows below:
This is a patch to make allow disabling element handlers in the
xml extension.
The documentation for xml_set_default_handler,
xml_set_element_handler, xml_set_external_entity_ref_handler, etc.
states "If a handler function is set to an empty string, or FALSE, the
handler in question is disabled." This doesn't seem to work cleanly
in the current source, instead a warning message is generated.
I'm sadly ignorant about writing proper C for PHP, please forgive my
any grievous errors in the code. Please also forgive me if I am
misunderstanding the documentation and this is a feature which
actually shouldn't be present in PHP.
I forwarded this patch already to Thies Arntzen who is listed is the
extension maintainer, but he says he is not currently working on the
PHP project.
----------
Some sample code to replicate this problem is:
<?
function startElement($parser, $name, $attrs) {
print "start element $name\n";
}
$parser = xml_parser_create();
xml_set_element_handler($parser, 'startElement', FALSE);
xml_parse($parser, "<tag/>", true);
xml_parser_free($parser);
?>
----------
With 5.0.2 and current CVS PHP I see:
start element TAG
Warning: xml_parse(): Unable to call handler () in
/home/dtorop/src/comet/dp/scripts/xmlbug.php on line 8
----------
With the patched code I see:
start element TAG
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php