mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
* Source/NSXMLNode.m (-copyWithZone_): Use value 1 instead of 2
for deep copy. Bug found by Doug Simons <doug.simons@testplant.com>. * Source/NSXMLNode.m (-rootDocument): Don't return the private document. * Source/NSXMLNode.m (-nextSibling, -previousSibling): Protect against namspace nodes. * Tests/base/NSXMLNode/transfer.m: New test case for problem reported by Doug Simons. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34988 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
887362645d
commit
511ebc6580
3 changed files with 72 additions and 4 deletions
|
@ -1147,7 +1147,7 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
|
|||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
NSXMLNode *c = [[self class] allocWithZone: zone];
|
||||
xmlNodePtr newNode = xmlCopyNode([self _node], 2); // make a deep copy
|
||||
xmlNodePtr newNode = xmlCopyNode([self _node], 1); // make a deep copy
|
||||
clearPrivatePointers(newNode);
|
||||
|
||||
c = [c _initWithNode: newNode kind: internal->kind];
|
||||
|
@ -1591,7 +1591,17 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
|
|||
|
||||
- (NSXMLNode*) nextSibling
|
||||
{
|
||||
return [NSXMLNode _objectForNode: internal->node->next];
|
||||
xmlNodePtr node = internal->node;
|
||||
|
||||
if (NULL == node)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if (XML_NAMESPACE_DECL == node->type)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return [NSXMLNode _objectForNode: node->next];
|
||||
}
|
||||
|
||||
- (id) objectValue
|
||||
|
@ -1648,13 +1658,40 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
|
|||
|
||||
- (NSXMLNode*) previousSibling
|
||||
{
|
||||
return [NSXMLNode _objectForNode: internal->node->prev];
|
||||
xmlNodePtr node = internal->node;
|
||||
|
||||
if (NULL == node)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if (XML_NAMESPACE_DECL == node->type)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return [NSXMLNode _objectForNode: node->prev];
|
||||
}
|
||||
|
||||
- (NSXMLDocument*) rootDocument
|
||||
{
|
||||
xmlNodePtr node = internal->node;
|
||||
|
||||
if (NULL == node)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if (XML_NAMESPACE_DECL == node->type)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if (NULL == node->parent)
|
||||
{
|
||||
// This is a standalone node, we still may have a private document,
|
||||
// but we don't want to return this.
|
||||
return nil;
|
||||
}
|
||||
|
||||
return
|
||||
(NSXMLDocument *)[NSXMLNode _objectForNode: (xmlNodePtr)(internal->node->doc)];
|
||||
(NSXMLDocument *)[NSXMLNode _objectForNode: (xmlNodePtr)(node->doc)];
|
||||
}
|
||||
|
||||
- (NSString*) stringValue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue