Re: [xml] modifying tree and attributes



On Sun, Oct 23, 2005 at 08:16:31AM -0400, Rob Richards wrote:
I was looking at bug 319108 (which I agree with assement and additional 
function needed) and was adding in some additional fixes from code I use.
i.e. - dont unlink or free if XML_ATTRIBUTE_DECL returned from xmlHasXXXProp
   - dont add attr if #FIXED in DTD

These changes affect xmlAddNextSibling, xmlAddPrevSibling and 
xmlAddChild. imo these are higher level functions so all checks should 
be done, but...

Where is the line drawn on what is expected the caller to handle and 
what the lib handles?

  I would say the library should be made as resilient as possible.

Looking at the bug, xmlAddChild() code and xmlHasNsProp() it seems
to me that xmlHasProp() should never be called and 
    lastattr = xmlHasNsProp(parent, cur->name, NULL);
should be used instead if cur->ns is NULL. bug #319108 should be just
fixed that way IMHO.

Looking at a few other functions:
xmlNewXXXProp - imo up to caller to handle checks as code does no checks 
for anything so no issues here.

  Adding such DTD related checks in xmlNewPropInternal() and trying to
channel all modification to attributes on that routine sounds the right
approach to me (i.e. only one copy of the code, as complex and strict as
need to be).

xmlSetXXXProp - grey area here. function checks for exsiting attribute 
and IDs but not XML_ATTRIBUTE_DECL (really only #FIXED would cause any 
problems). But in the case ofsetting a prop with ns, it is up to the 
caller to insure ns is in scope. so basically some things handled here 
while others arent.

  I would not check the scopedness of the attribute passed there (it may
not yet have been added to the element), but I would check the type of the
attribute to avoid breaking #FIXED, and potentially other checks which may
be needed.
  I take patches :-)

-- 
Daniel Veillard      | Red Hat http://redhat.com/
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]