avoid undef errors blowing out XML::Tags
Matt S Trout [Thu, 10 Feb 2011 18:17:01 +0000 (18:17 +0000)]
lib/XML/Tags.pm

index 9249691..8b30b60 100644 (file)
@@ -26,7 +26,11 @@ sub to_xml_string {
     ref($_)
       ? (ref $_ eq 'SCALAR' ? $$_ : $_)
       : do { local $_ = $_; # copy
-          s/&/&amp;/g; s/"/&quot;/g; s/</&lt;/g; s/>/&gt;/g; $_;
+          if (defined) {
+            s/&/&amp;/g; s/"/&quot;/g; s/</&lt;/g; s/>/&gt;/g; $_;
+          } else {
+            ''
+          }
         }
   } @_
 }