pplu / aws-sdk-perl

A community AWS SDK for Perl Programmers
Other
171 stars 94 forks source link

ForceArray changed in Paws::Net::RestXMLResponse #184

Open spazm opened 7 years ago

spazm commented 7 years ago

The XML::Simple ForceArray regex flipped in value and is now opposite between Paws::Net::RestXMLResponse and Paws::Net::XMLReponse.

Can we confirm a consistent good value for this between these two XMLResponse modules?

  1. Commit 0aa0ea6e in June 2017 pulled the inverting match ^ outside of the ForceArray regex grouping parens, inverting the whole match rather than just item and removed the trailing anchor. Was this purposeful?
    • ForceArray => qr/^(?:item|Errors)/i,
  2. The inverted match on item was added in 13ca007b86 to keep from matching MaxItems into an array:
    • ForceArray => [ qr/(?:^item$|Errors)/i, ]
  3. Paws::Net::XMLReponse doesn't have any limit on it's match:
    • ForceArray => qr/(?:item|Errors)/i,
commit 0aa0ea6e393f561edce99c28d0659ee05d4e8b7e                          
Author: Jose Luis Martinez <jlmartinez@capside.com>                      
Date:   Wed Jun 7 16:16:45 2017 +0000                                    

    Work on properly handling malformed responses                        

diff --git a/lib/Paws/Net/RestXMLResponse.pm b/lib/Paws/Net/RestXMLResponse.pm                                                                    
index beac24605..fcd790240 100644   
--- a/lib/Paws/Net/RestXMLResponse.pm                                    
+++ b/lib/Paws/Net/RestXMLResponse.pm                                    
@@ -9,44 +9,37 @@ package Paws::Net::RestXMLResponse;                    
     my ($self, $data) = @_;        

     return {} if (not defined $data or $data eq '');                    
-                                   
-    my $xml = XML::Simple::XMLin( $data,                                
-            ForceArray    => [ qr/(?:^item$|Errors)/i, ],               
-            KeyAttr       => '',   
-            SuppressEmpty => undef,                                     
+                                   
+    my $xml = XML::Simple->new(    
+      ForceArray    => qr/^(?:item|Errors)/i,                           
+      KeyAttr       => '',         
+      SuppressEmpty => undef,      
     );                             
-    return $xml;                   
+    return $xml->parse_string($data);                                   
   }   

cpan-prc #team-ziprecruiter

pplu commented 7 years ago

Hi! This will be fixed in next releases. Thanks for the suggestion. The intention is to take the "refactor" branches that are not merged yet, and merge them for the next release. This should include the change you suggest.