tag 432513 patch thanks On Tue, Jul 10, 2007 at 12:40:20PM +0300, Niko Tyni wrote:
> This regression comes from libxml-libxml-perl 1.63-1 > /usr/lib/perl5/auto/XML/LibXML/LibXML.so, which segfaults: > > % perl -Iblib/lib t/02-create.t > [...] > ok 12 - feed modified is correct > ok 13 - feed generator is correct > Segmentation fault (core dumped) This is apparently the same issue as CPAN #26450, fixed in upstream SVN (svn://axkit.org/XML-LibXML/trunk) r664. Patch attached; this fixes the segmentation fault for me and makes libxml-feed-perl build again. Cheers, -- Niko Tyni [EMAIL PROTECTED]
Index: perl-libxml-mm.h =================================================================== --- perl-libxml-mm.h (revision 663) +++ perl-libxml-mm.h (revision 664) @@ -40,7 +40,7 @@ * for warn!! */ #ifdef XS_WARNINGS -#define xs_warn(string) warn(string) +#define xs_warn(string) warn("%s",string) #else #define xs_warn(string) #endif Index: dom.c =================================================================== --- dom.c (revision 663) +++ dom.c (revision 664) @@ -14,7 +14,7 @@ /* #define warn(string) fprintf(stderr, string) */ #ifdef XS_WARNINGS -#define xs_warn(string) warn(string) +#define xs_warn(string) warn("%s",string) #else #define xs_warn(string) #endif @@ -91,9 +91,20 @@ _domReconcileNsAttr(xmlAttrPtr attr, xmlNsPtr * unused) { xmlNodePtr tree = attr->parent; + if (tree == NULL) + return; if( attr->ns != NULL ) { - xmlNsPtr ns = xmlSearchNs( tree->doc, tree->parent, attr->ns->prefix ); + xmlNsPtr ns; + if ((attr->ns->prefix != NULL) && + (xmlStrEqual(attr->ns->prefix, BAD_CAST "xml"))) { + /* prefix 'xml' has no visible declaration */ + ns = xmlSearchNsByHref(tree->doc, tree, XML_XML_NAMESPACE); + attr->ns = ns; + return; + } else { + ns = xmlSearchNs( tree->doc, tree->parent, attr->ns->prefix ); + } if( ns != NULL && ns->href != NULL && attr->ns->href != NULL && xmlStrcmp(ns->href,attr->ns->href) == 0 ) { @@ -114,7 +125,9 @@ { /* Replace/Add the namespace declaration on the element */ attr->ns = xmlCopyNamespace(attr->ns); - domAddNsDef(tree, attr->ns); + if (attr->ns) { + domAddNsDef(tree, attr->ns); + } } } } Index: t/10ns.t =================================================================== --- t/10ns.t (revision 663) +++ t/10ns.t (revision 664) @@ -1,6 +1,6 @@ # -*- cperl -*- use Test; -BEGIN { plan tests=>122; } +BEGIN { plan tests=>124; } use XML::LibXML; use XML::LibXML::Common qw(:libxml); @@ -384,3 +384,15 @@ ok ( !defined($child->getAttribute( 'xmlns:other' )) ); ok ( defined($doca->documentElement->getAttribute( 'xmlns:other' )) ); } + +print "# 10. xml namespace\n"; +{ + my $docOne = XML::LibXML->new->parse_string('<foo><inc xml:id="test"/></foo>'); + my $docTwo = XML::LibXML->new->parse_string('<bar><urgh xml:id="foo"/></bar>'); + + my $inc = $docOne->getElementById('test'); + my $rep = $docTwo->getElementById('foo'); + $inc->parentNode->replaceChild($rep, $inc); + ok($inc->getAttributeNS('http://www.w3.org/XML/1998/namespace','id'),'test'); + ok($inc->isSameNode($docOne->getElementById('test'))); +} Index: Changes =================================================================== --- Changes (revision 663) +++ Changes (revision 664) @@ -1,5 +1,8 @@ Revision history for Perl extension XML::LibXML +pre1.64 + - fix reconcilation of the "xml" namespace [rt.cpan.org #26450] + 1.63 - added no_network parser flag - added support for exclusive canonicalization (http://www.w3.org/TR/xml-exc-c14n/)