Re: [xml] Losing _private for external entities [Was: What is the _private field actually for?]



On Fri, Sep 29, 2006 at 04:40:54PM +1000, Michael Day wrote:
Hi Daniel,

 Sure, it is likely to end up being in or around 
xmlParseExternalEntityPrivate() in parser.c though it already copies
_private if oldctxt is provided. I could chase this, I may be a bit faster
than you, but having other people learn about the code is IMHO a good thing
so if you're not afraid, go for it, definitely !

The problem seems to be here: xmlParseCtxtExternalEntity calls 
xmlCreateEntityParserCtxt, which creates a new parser context from 
nothing and does not take an old parser context to copy the _private 
data from.

  Hum, it does put the _private but *after* the creation:

: ctxt = xmlCreateEntityParserCtxt(URL, ID, NULL);
: if (ctxt == NULL) return(-1);
: ctxt->userData = ctxt;
: ctxt->_private = ctx->_private;

Would the best way to fix it be to just pass a context into 
xmlCreateEntityParserCtxt, or perhaps just pass in the value of _private 
to be copied into the new context?

  You can't change xmlCreateEntityParserCtxt() it's a public API.
The simplest is probably to embbed some of the code of
xmlCreateEntityParserCtxt into xmlParseCtxtExternalEntity, making sure
that _private is copied between xmlNewParserCtxt() and the
xmlLoadExternalEntity() . We don't use a base, so some of the code may
be simplified. 
  If you don't feel okay hacking this I will, but you're in a better
position to test the change :-)

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]