]> granicus.if.org Git - php/commitdiff
send some more data to the default handler
authorSterling Hughes <sterling@php.net>
Mon, 19 May 2003 21:51:57 +0000 (21:51 +0000)
committerSterling Hughes <sterling@php.net>
Mon, 19 May 2003 21:51:57 +0000 (21:51 +0000)
libxml2 is braindead when it comes to handling entities

ext/xml/compat.c

index 9b9b1c41276b7ee62ea1a2b35c38c5e4e6f58d38..c22a4c29c6770ce4f0414a24aabe15060c5f0795 100644 (file)
@@ -209,6 +209,33 @@ _comment_handler(void *user, const xmlChar *comment)
        }
 }
 
+static void
+_build_entity(const xmlChar *name, int len, xmlChar **entity, int *entity_len) 
+{
+       *entity_len = len + 2;
+       *entity = xmlMalloc(*entity_len + 1);
+       (*entity)[0] = '&';
+       memcpy(*entity+1, name, len);
+       (*entity)[len+1] = ';';
+       (*entity)[*entity_len] = '\0';
+}
+
+static xmlEntityPtr
+_get_entity(void *user, const xmlChar *name)
+{
+       XML_Parser parser = (XML_Parser) user;
+
+       if (parser->h_default) {
+               xmlChar *entity;
+               int      len;
+               
+               _build_entity(name, xmlStrlen(name), &entity, &len);
+               parser->h_default(parser->user, (const xmlChar *) entity, len);
+       }
+
+       return NULL;
+}
+
 static void
 _external_entity_ref_handler(void *user, const xmlChar *names, int type, const xmlChar *sys_id, const xmlChar *pub_id, xmlChar *content)
 {
@@ -218,7 +245,7 @@ _external_entity_ref_handler(void *user, const xmlChar *names, int type, const x
                return;
        }
 
-       parser->h_external_entity_ref(parser, names, NULL, sys_id, pub_id);
+       parser->h_external_entity_ref(parser, names, "", sys_id, pub_id);
 }
 
 static xmlSAXHandler 
@@ -228,7 +255,7 @@ php_xml_compat_handlers = {
        NULL, /* hasInternalSubset */
        NULL, /* hasExternalSubset */
        NULL, /* resolveEntity */
-       NULL, /* getEntity */
+       _get_entity, /* getEntity */
        _external_entity_ref_handler, /* entityDecl */
        _notation_decl_handler,
        NULL, /* attributeDecl */