Skip Menu |

This queue is for tickets about the Net-OpenSRS CPAN distribution.

Report information
The Basics
Id: 46939
Status: resolved
Worked: 4 hours (240 min)
Priority: 0/
Queue: Net-OpenSRS

People
Owner: richard.siddall [...] elirion.net
Requestors: richard.siddall [...] elirion.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.02
Fixed in: 0.03



Subject: Invalid XML in OpenSRS renew response causes XML parser exception.
While testing renewals using the OpenSRS test system I got an exception from the XML parser in make_request complaining that the name of one of the XML elements (registration expiration date) in the response for the renew operation contains spaces. Converting the spaces to underscores fixes the problem.
Subject: Net-OpenSRS.traceback.txt
not well-formed (invalid token) at line 5, column 27, byte 142 at /usr/lib/perl5/XML/Parser.pm line 187 Trace begun at /usr/share/perl5/HTML/Mason/Exceptions.pm line 129 HTML::Mason::Exceptions::rethrow_exception('^Jnot well-formed (invalid token) at line 5, column 27, byte 142 at /usr/lib/perl5/XML/Parser.pm line 187^J') called at /usr/share/perl/5.8/Carp.pm line 102 Carp::croak('^Jnot well-formed (invalid token) at line 5, column 27, byte 142') called at /usr/lib/perl5/XML/Parser/Expat.pm line 478 XML::Parser::Expat::parse('XML::Parser::Expat=HASH(0xb83b48c)', '<opt>^J <admin_email>nobody@example.com</admin_email>^J <auto_renew>0</auto_renew>^J <order_id>1058226</order_id>^J <registration expiration date>2015-05-15 19:22:24</registration expiration date>^J</opt>^J') called at /usr/lib/perl5/XML/Parser.pm line 187 eval {...} at /usr/lib/perl5/XML/Parser.pm line 186 XML::Parser::parse('XML::Parser=HASH(0xb6d49a4)', '<opt>^J <admin_email>nobody@example.com</admin_email>^J <auto_renew>0</auto_renew>^J <order_id>1058226</order_id>^J <registration expiration date>2015-05-15 19:22:24</registration expiration date>^J</opt>^J') called at /usr/share/perl5/XML/SAX/Expat.pm line 60 XML::SAX::Expat::_parse_string('XML::SAX::Expat=HASH(0xb8713b8)', '<opt>^J <admin_email>nobody@example.com</admin_email>^J <auto_renew>0</auto_renew>^J <order_id>1058226</order_id>^J <registration expiration date>2015-05-15 19:22:24</registration expiration date>^J</opt>^J') called at /usr/share/perl5/XML/SAX/Base.pm line 2602 XML::SAX::Base::parse('XML::SAX::Expat=HASH(0xb8713b8)', 'HASH(0xb84c488)') called at /usr/share/perl5/XML/SAX/Base.pm line 2655 XML::SAX::Base::parse_string('XML::SAX::Expat=HASH(0xb8713b8)', '<opt>^J <admin_email>nobody@example.com</admin_email>^J <auto_renew>0</auto_renew>^J <order_id>1058226</order_id>^J <registration expiration date>2015-05-15 19:22:24</registration expiration date>^J</opt>^J') called at /usr/share/perl5/XML/Simple.pm line 370 XML::Simple::build_tree('XML::Simple=HASH(0xb84c2f0)', undef, 'SCALAR(0xb86dff4)') called at /usr/share/perl5/XML/Simple.pm line 308 XML::Simple::build_simple_tree('XML::Simple=HASH(0xb84c2f0)', undef, 'SCALAR(0xb86dff4)') called at /usr/share/perl5/XML/Simple.pm line 270 XML::Simple::parse_string('XML::Simple=HASH(0xb84c2f0)', 'SCALAR(0xb86dff4)') called at /usr/share/perl5/XML/Simple.pm line 171 XML::Simple::XMLin('<opt>^J <admin_email>nobody@example.com</admin_email>^J <auto_renew>0</auto_renew>^J <order_id>1058226</order_id>^J <registration expiration date>2015-05-15 19:22:24</registration expiration date>^J</opt>^J') called at /usr/local/share/perl/5.8.8/Net/OpenSRS.pm line 1175 Net::OpenSRS::make_request('Net::OpenSRS=HASH(0xb3b8ac4)', 'HASH(0xb3c02a8)') called at /usr/local/share/perl/5.8.8/Net/OpenSRS.pm line 961 Net::OpenSRS::renew_domain('Net::OpenSRS=HASH(0xb3b8ac4)', 'example.com', 1) called at /usr/local/share/perl/5.8.8/FS/part_export/domreg_opensrs.pm line 461
Subject: OpenSRS.pm.diff
--- OpenSRS.pm.orig 2006-04-08 22:26:22.000000000 +0000 +++ OpenSRS.pm 2009-06-14 22:07:32.000000000 +0000 @@ -1159,7 +1159,10 @@ my $struct; if ( $res->is_success ) { $self->debug("HTTP result: " . $res->status_line); - eval { $struct = XML::Simple::XMLin( $res->content); }; + my $rslt = $res->content; + # OpenSRS renew response triggers parser error due to spaces in element name + $rslt =~ s/registration expiration date/registration_expiration_date/g; + eval { $struct = XML::Simple::XMLin( $rslt ); }; if ($self->debug_level > 1) { $self->debug("\nOpenSRS Response XML:\n" . '-' x 30);
Applied a the suggested fix with a slightly modified comment. It now looks like XML::Simple uses the Expat parser if it's installed, and it's Expat that throws an exception due to the invalid XML element name in the OpenSRS renew response. That explains why some users don't see the problem; they're using different parsers. A more elegant fix would be welcome. I'm assuming that doing an unconditional replacement of the element name in all responses doesn't harm performance.