Commit 1c527b6b authored by Jonathon Duerig's avatar Jonathon Duerig

Fix XML. Don't try to canonicalize to print. That has too much unwanted...

Fix XML. Don't try to canonicalize to print. That has too much unwanted baggage. Create a copy of the node instead which will automatically add namespace declarations to it.
parent bd3210aa
......@@ -663,7 +663,7 @@ sub GetManifest($$)
return $manifest
if (!$asxml);
$xml = $manifest->toStringC14N();
$xml = GeniXML::Serialize($manifest);
return $xml;
}
......
......@@ -691,7 +691,7 @@ sub GetTicketAuxAux($$$$$$$$)
}
}
print $rspec->toStringC14N();
print GeniXML::Serialize($rspec);
foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) {
my $resource_uuid = GeniXML::GetNodeId($ref);
......@@ -1150,7 +1150,7 @@ sub GetTicketAuxAux($$$$$$$$)
}
unlink($tmpfile);
print $solution->toStringC14N();
print GeniXML::Serialize($solution);
foreach my $ref (GeniXML::FindNodes("n:node",
$solution)->get_nodelist()) {
......@@ -1239,7 +1239,7 @@ sub GetTicketAuxAux($$$$$$$$)
goto bad;
}
print $rspec->toStringC14N();
print GeniXML::Serialize($rspec);
# Nalloc might fail if the node gets picked up by someone else.
if (@nodeids && !$impotent) {
......@@ -1274,7 +1274,7 @@ sub GetTicketAuxAux($$$$$$$$)
# Create a new ticket.
#
my $newticket = GeniTicket->Create($authority, $user,
$rspec->toStringC14N());
GeniXML::Serialize($rspec));
if (!defined($newticket)) {
$response =
GeniResponse->Create(GENIRESPONSE_ERROR, undef,
......@@ -1559,7 +1559,7 @@ sub SliverWorkAux($$$$$$$)
my @freelinks= ();
my $needplabslice = 0;
print $rspec->toStringC14N();
print GeniXML::Serialize($rspec);
#
# Find current slivers and save.
......@@ -2265,7 +2265,7 @@ sub SliverWorkAux($$$$$$$)
}
# The Manifest.
my $manifest = $rspec->toStringC14N();
my $manifest = GeniXML::Serialize($rspec);
#
# Move this elsewhere.
......@@ -2611,7 +2611,7 @@ sub StartSliver($)
}
if (defined($manifest)) {
print $manifest->toStringC14N();
print GeniXML::Serialize($manifest);
#
# This is not signed, so have to be very careful about using
......@@ -3401,7 +3401,7 @@ sub SliverTicket($)
POSIX::strftime("20%y-%m-%dT%H:%M:%S",
gmtime(str2time($slice->expires()))));
my $rspec_xml = $rspec->toStringC14N();
my $rspec_xml = GeniXML::Serialize($rspec);
#
# Create a new ticket.
......@@ -4073,7 +4073,7 @@ sub UpdateManifest($)
}
}
my $manifest = $rspec->toStringC14N();
my $manifest = GeniXML::Serialize($rspec);
#
# Move this elsewhere.
......
......@@ -408,7 +408,8 @@ sub DeleteSliver($)
$response = GeniResponse->Create(GENIRESPONSE_ERROR);
goto bad;
}
my $ticket = GeniTicket->Create($authority, $user, $manifest->toStringC14N());
my $ticket = GeniTicket->Create($authority, $user,
GeniXML::Serialize($manifest));
if (!defined($ticket)) {
print STDERR "Could not create new ticket for $slice\n";
$response = GeniResponse->Create(GENIRESPONSE_ERROR);
......
......@@ -431,7 +431,7 @@ sub Sign($$)
if ($self->extensions()->size() > 0) {
$cap_xml .= "<extensions>\n";
foreach my $node ($self->extensions()->get_nodelist()) {
$cap_xml .= $node->toStringC14N();
$cap_xml .= GeniXML::Serialize($node);
}
$cap_xml .= "</extensions>\n";
}
......
......@@ -320,7 +320,7 @@ sub UpdateManifest($$)
return -1;
}
my $manifest_idx = $self->manifest_idx();
my $manifest_string = $manifest->toStringC14N();
my $manifest_string = GeniXML::Serialize($manifest);
my $query_result =
DBQueryWarn("update geni_manifests set ".
......@@ -363,7 +363,7 @@ sub GetTicket($$$$)
gmtime(time() + (3600*6))));
}
my $rspec_string = $rspec->toStringC14N();
my $rspec_string = GeniXML::Serialize($rspec);
#
# Load the SA cert to act as caller context.
......
......@@ -197,7 +197,7 @@ sub Create($$$$$$$$$)
push(@insert_data, "slice_uuid='$slice_uuid'");
if (defined($rspec)) {
my $rspec_string = $rspec->toStringC14N();
my $rspec_string = GeniXML::Serialize($rspec);
my $safe_rspec = DBQuoteSpecial($rspec_string);
push(@insert_data, "rspec_string=$safe_rspec");
......@@ -301,7 +301,7 @@ sub GetManifest($$)
return $manifest
if (!$asxml);
my $xml = $self->rspec()->toStringC14N();
my $xml = GeniXML::Serialize($self->rspec());
return $xml;
}
......
......@@ -578,7 +578,7 @@ sub rspecXML($)
return undef
if (!defined($self->rspec()));
return $self->rspec()->toStringC14N();
return GeniXML::Serialize($self->rspec());
}
#
......@@ -710,7 +710,7 @@ sub RunSigner($$)
my $target_cert = $self->target_cert()->cert();
my $owner_cert = $self->owner_cert()->cert();
my $ticket_uuid = $self->{'ticket_uuid'};
my $rspec_xml = $self->rspec()->toStringC14N();
my $rspec_xml = GeniXML::Serialize($self->rspec());
# Convert to GMT.
$expires = POSIX::strftime("20%y-%m-%dT%H:%M:%S",
......@@ -803,7 +803,7 @@ sub Release($$)
my $resource_uuid = GeniXML::GetNodeId($ref);
if (!defined($resource_uuid)) {
print STDERR "No resource id for node in ticket\n";
print $ref->toStringC14N();
print GeniXML::Serialize($ref);
return -1;
}
......@@ -878,7 +878,7 @@ sub ReleaseHolding($$)
my $resource_uuid = GeniXML::GetNodeId($ref);
if (!defined($resource_uuid)) {
print STDERR "No resource id for node in ticket\n";
print $ref->toStringC14N();
print GeniXML::Serialize($ref);
return -1;
}
......
......@@ -68,7 +68,7 @@ sub NewSliver($$$$)
}
}
if (defined($sliver->rspec())) {
my $rspec_string = $sliver->rspec()->toStringC14N();
my $rspec_string = GeniXML::Serialize($sliver->rspec());
my $safe_rspec = DBQuoteSpecial($rspec_string);
push(@insert_data, "rspec_string=$safe_rspec");
......@@ -310,7 +310,7 @@ sub NewManifest($$$)
my @insert_data = ();
my $aggregate_uuid = $aggregate->uuid();
my $manifest_string = $manifest->toStringC14N();
my $manifest_string = GeniXML::Serialize($manifest);
my $safe_manifest = DBQuoteSpecial($manifest_string);
# Insert into DB.
......
......@@ -244,6 +244,17 @@ sub GetText($$)
return $result;
}
# Converts the XML representation of a node to a UTF-8 string and
# outputs it as a complete XML document.
sub Serialize($)
{
my ($node) = @_;
my $newnode = $node->cloneNode(1);
return $newnode->toString();
}
# Create a new XML document with a given namespace URI and document
# element name.
sub CreateDocument($$)
{
my ($ns, $name) = @_;
......@@ -253,6 +264,8 @@ sub CreateDocument($$)
return $doc;
}
# Add a new element to a node. The new element will have the given
# name and be otherwise empty.
sub AddElement($$)
{
my ($name, $node) = @_;
......@@ -261,6 +274,8 @@ sub AddElement($$)
return $child;
}
# Remove a node with a given name from a node. It will be removed
# whether it is an attribute or an element. The name is not an xpath.
sub RemoveChild($$)
{
my ($name, $node) = @_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment