Browse files

merge patches

  • Loading branch information...
1 parent 8fe5058 commit f002fb893fb5699d501d128dc0708d20b28f07a2 @djzort committed Dec 12, 2013
Showing with 78 additions and 52 deletions.
  1. +3 −0 Changes
  2. +1 −1 lib/BZ/Client.pm
  3. +68 −45 lib/BZ/Client/XMLRPC/Value.pm
  4. +6 −6 t/10parser.t
View
3 Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension BZ::Client.
+1.06 Thu Dec 12 14:06:00 2013
+ - Applied path from https://rt.cpan.org/Public/Bug/Display.html?id=78467, needs a test.
+
1.05 Fri Nov 29 14:11:00 2013
- Applied patch from http://hg.mozilla.org/webtools/bzapi/raw-file/24eba717cf5b/patches/xmlrpc-fix.diff
View
2 lib/BZ/Client.pm
@@ -9,7 +9,7 @@ package BZ::Client;
use BZ::Client::XMLRPC();
use HTTP::Cookies();
-our $VERSION = '1.05';
+our $VERSION = '1.06';
sub new($%) {
my $class = shift;
View
113 lib/BZ/Client/XMLRPC/Value.pm
@@ -4,89 +4,112 @@
package BZ::Client::XMLRPC::Value;
use strict;
-use warnings "all";
+use warnings 'all';
use BZ::Client::XMLRPC::Handler();
use BZ::Client::XMLRPC::Struct();
use BZ::Client::XMLRPC::Array();
use DateTime::Format::ISO8601();
-our $VERSION = 1.0;
-our @ISA = qw(BZ::Client::XMLRPC::Handler);
+our $VERSION = 1.01;
+our @ISA = qw(BZ::Client::XMLRPC::Handler);
sub start($$) {
- my($self,$name) = @_;
+ my ( $self, $name ) = @_;
my $l = $self->inc_level();
- if ($l == 0) {
- if ("value" ne $name) {
+ if ( $l == 0 ) {
+ if ( 'value' ne $name ) {
$self->error("Expected value element, got $name");
}
- $self->{'level0_content'} = "";
- } elsif ($l == 1) {
- if ("struct" eq $name) {
+ $self->{'level0_content'} = q();
+ }
+ elsif ( $l == 1 ) {
+ if ( 'struct' eq $name ) {
my $handler = BZ::Client::XMLRPC::Struct->new();
- $self->parser()->register($self, $handler, sub {
- $self->{'result'} = $handler->result();
- });
+ $self->parser()->register(
+ $self, $handler,
+ sub {
+ $self->{'result'} = $handler->result();
+ }
+ );
$handler->start($name);
- } elsif ("array" eq $name) {
+ }
+ elsif ( 'array' eq $name ) {
my $handler = BZ::Client::XMLRPC::Array->new();
- $self->parser()->register($self, $handler, sub {
- $self->{'result'} = $handler->result();
- });
+ $self->parser()->register(
+ $self, $handler,
+ sub {
+ $self->{'result'} = $handler->result();
+ }
+ );
$handler->start($name);
- } elsif ("i4" eq $name
- || "int" eq $name
- || "string" eq $name
- || "double" eq $name
- || "dateTime.iso8601" eq $name
- || "base64" eq $name
- || "boolean" eq $name) {
- $self->{'level1_elem'} = $name;
+ }
+ elsif ('i4' eq $name
+ || 'int' eq $name
+ || 'string' eq $name
+ || 'double' eq $name
+ || 'dateTime.iso8601' eq $name
+ || 'base64' eq $name
+ || 'boolean' eq $name )
+ {
+ $self->{'level1_elem'} = $name;
$self->{'level1_content'} = "";
- } else {
- $self->error("Expected struct|array|i4|int|boolean|string|double|dateTime.iso8601|base64 element, got $name");
}
- } else {
+ else {
+ $self->error(
+"Expected struct|array|i4|int|boolean|string|double|dateTime.iso8601|base64 element, got $name"
+ );
+ }
+ }
+ else {
$self->error("Unexpected element $name at level $l");
}
}
sub end($$) {
- my($self,$name) = @_;
+ my ( $self, $name ) = @_;
my $l = $self->level();
- if ($l == 1) {
+ if ( $l == 1 ) {
my $content = $self->{'level0_content'};
- if (defined($self->{'result'})) {
- if ($content !~ /^\s*$/s) {
- $self->error("Unexpected non-whitespace content");
+ if ( defined( $self->{'result'} ) ) {
+ if ( $content !~ m/^\s*$/s ) {
+ $self->error('Unexpected non-whitespace content');
}
- } else {
+ }
+ else {
$self->{'result'} = $content;
}
- } elsif ($l == 2) {
+ }
+ elsif ( $l == 2 ) {
my $name = $name;
- if (defined($name)) {
- $self->{'result'} = $self->{'level1_content'};
+ if ( defined($name) ) {
+ $self->{'result'} = $self->{'level1_content'};
$self->{'level1_content'} = undef;
- $self->{'level1_elem'} = undef;
- if ("dateTime.iso8601" eq $name) {
- $self->{'result'} = DateTime::Format::ISO8601->parse_datetime( $self->{'result'} );
- }
+ $self->{'level1_elem'} = undef;
+ if ( 'dateTime.iso8601' eq $name ) {
+ my $val = $self->{'result'};
+ if ( $val =~ m/(\d\d\d\d)(\d\d)(\d\d)(T\d\d:\d\d:\d\d)/ )
+ { # See https://rt.cpan.org/Public/Bug/Display.html?id=78467
+ $val = "$1-$2-$3$4";
+ }
+ $self->{'result'} =
+ DateTime::Format::ISO8601->parse_datetime($val);
+ }
}
}
return $self->SUPER::end($name);
}
sub characters($$) {
- my($self,$text) = @_;
+ my ( $self, $text ) = @_;
my $l = $self->level();
- if ($l == 1) {
+ if ( $l == 1 ) {
$self->{'level0_content'} .= $text;
return;
- } elsif ($l == 2) {
+ }
+ elsif ( $l == 2 ) {
my $l1_elem = $self->{'level1_elem'};
- if (defined($l1_elem)) {
+ if ( defined($l1_elem) ) {
$self->{'level1_content'} .= $text;
return;
}
@@ -95,7 +118,7 @@ sub characters($$) {
}
sub result($) {
- my($self) = shift;
+ my ($self) = shift;
my $res = $self->{'result'};
$res = defined($res) ? $res : "";
return $res;
View
12 t/10parser.t
@@ -48,7 +48,7 @@ sub parse_error($) {
sub TestBasic() {
my $doc = <<"EOF";
-<methodResponse>
+<methodResponse>
<params>
<param>
<value><string>South Dakota</string></value>
@@ -61,7 +61,7 @@ EOF
sub TestStrings() {
my $doc = <<"EOF";
-<methodResponse>
+<methodResponse>
<params>
<param>
<value>
@@ -95,7 +95,7 @@ EOF
my $res2 = $result->[2];
if ("DateTime" ne ref($res2)){
return "Expected DateTime, got ". ref($res2);
- }
+ }
if ($res2->year != 2011){
return "Expected year 2022, got " . $res2-> year();
}
@@ -117,13 +117,13 @@ EOF
if ($res2->time_zone->name() ne 'UTC'){
return "Expectead timezone UTC, got " . $res2->time_zone->name();
}
-
+
return undef;
}
sub TestStructure() {
my $doc = <<"EOF";
-<methodResponse>
+<methodResponse>
<params>
<param>
<value>
@@ -162,7 +162,7 @@ EOF
sub TestFault() {
my $doc = <<"EOF";
-<methodResponse>
+<methodResponse>
<fault>
<value>
<struct>

0 comments on commit f002fb8

Please sign in to comment.