Add tests to not load files that are not valid/sane class names (from theorbtwo)
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Engine.pm
index 347f781..089a959 100644 (file)
@@ -625,6 +625,11 @@ sub write {
     my $len   = length($buffer);
     my $wrote = syswrite STDOUT, $buffer;
     
+    if ( !defined $wrote && $! == EWOULDBLOCK ) {
+        # Unable to write on the first try, will retry in the loop below
+        $wrote = 0;
+    }
+    
     if ( defined $wrote && $wrote < $len ) {
         # We didn't write the whole buffer
         while (1) {
@@ -653,10 +658,9 @@ as Apache may implement this using Apache's C-based modules, for example.
 
 sub unescape_uri {
     my ( $self, $str ) = @_;
-    
-    $str =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
-    $str =~ s/\+/ /g;
-    
+
+    $str =~ s/(?:%([0-9A-Fa-f]{2})|\+)/defined $1 ? chr(hex($1)) : ' '/eg;
+
     return $str;
 }