[xml] Glitch with external entity files; patch enclosed

Date view Thread view Subject view Author view

From: Kenneth Pronovici (pronovic@skyjammer.com)
Date: Wed Nov 08 2000 - 17:11:29 EST


We have been seeing problems with external entity files included in DTDs,
in our case when using an external entity loader. We're using 2.2.7.

Since all of my DTDs are stored in "/dvl/fds/dtd", my external entity loader
takes the URL it's passed and tacks "/dvl/fds/dtd" on the front, so libxml
can find the DTD. Everything works fine as long as all of the definitions
are in a single file. However, as soon as I want to reference external files,
things break.

Suppose in my /dvl/fds/dtd directory we have a DTD file "complex.dtd"
which looks like this:

   <!ENTITY % header SYSTEM "complex.ent">
   
   %header;
   
   <!ELEMENT content (#PCDATA) >
   <!ELEMENT test_doc (%msg_hdr;, content) >
   
and a corresponding entities file "complex.ent" which looks like this:

   <!ENTITY % msg_hdr "msg_hdr ">
   
   <!ELEMENT head (#PCDATA) >
   <!ELEMENT %msg_hdr; (head) >

and we're trying to validate an XML document based on complex.dtd. In this
case, libxml uses resolves the two files as:

   /dvl/fds/dtd/complex.dtd
   /dvl/fds/dtd//dvl/fds/dtd/complex.ent

because of an extraneous call to xmlLoadExternalEntity() inside of
xmlNewEntityInputStream(). In this case, xmlGetEntityFromTable() has
already been used to retrieve

   /dvl/fds/dtd/complex.ent

for the msg_hdr tag, and there is no need to call xmlLoadExternalEntity().

I patched parserInternals.c by replacing the call to xmlLoadExternalEntity()
with a call to xmlNewInputFromFile(). This solves my immediate problem
and does not seem to break any regression tests, at least on my platform.
The patch is enclosed. If you'd rather fix it a different way, let me
know and I'll test your change as soon as I can.

Let me know if you need any other information from me.

KEN

--
Kenneth J. Pronovici <pronovic@ieee.org>
Alliance of Computer Professionals, Inc. (http://www.acpros.com/)
Personal Homepage: http://www.skyjammer.com/~pronovic/
"Hell hath no fury like the weather when I'm camping..." 

*** parserInternals.c.orig Wed Nov 8 15:07:12 2000 --- parserInternals.c Wed Nov 8 15:35:41 2000 *************** *** 1936,1943 **** break; case XML_EXTERNAL_GENERAL_PARSED_ENTITY: case XML_EXTERNAL_PARAMETER_ENTITY: ! return(xmlLoadExternalEntity((char *) entity->URI, ! (char *) entity->ExternalID, ctxt)); case XML_INTERNAL_GENERAL_ENTITY: if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) ctxt->sax->error(ctxt->userData, --- 1936,1942 ---- break; case XML_EXTERNAL_GENERAL_PARSED_ENTITY: case XML_EXTERNAL_PARAMETER_ENTITY: ! return(xmlNewInputFromFile(ctxt, entity->URI)); case XML_INTERNAL_GENERAL_ENTITY: if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) ctxt->sax->error(ctxt->userData,

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Nov 08 2000 - 17:44:24 EST