make uri_for unicode safe
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 3adfce2..1026625 100644 (file)
@@ -22,6 +22,7 @@ use Scalar::Util qw/weaken blessed/;
 use Tree::Simple qw/use_weak_refs/;
 use Tree::Simple::Visitor::FindByUID;
 use attributes;
+use utf8;
 use Carp qw/croak/;
 
 __PACKAGE__->mk_accessors(
@@ -854,6 +855,14 @@ sub uri_for {
     my $params =
       ( scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {} );
 
+    for my $value ( values %$params ) {\r
+        my $isa_ref = ref $value;\r
+        if( $isa_ref and $isa_ref ne 'ARRAY' ) {\r
+            croak( "Non-array reference ($isa_ref) passed to uri_for()" );\r
+        }\r
+        utf8::encode( $_ ) for $isa_ref ? @$value : $value;\r
+    };
+    
     # join args with '/', or a blank string
     my $args = ( scalar @args ? '/' . join( '/', @args ) : '' );
     $args =~ s/^\/// unless $path;
@@ -996,7 +1005,7 @@ perldoc <a href="http://cpansearch.perl.org/dist/Catalyst/lib/Catalyst/Manual.po
                          <a href="http://lists.rawmode.org/mailman/listinfo/catalyst">Mailing-List</a>
                      </li>
                      <li>
-                         <a href="irc://irc.perl.org/catalyst">IRC channel #catalyst-talk on irc.perl.org</a>
+                         <a href="irc://irc.perl.org/catalyst">IRC channel #catalyst on irc.perl.org</a>
                      </li>
                  </ul>
                  <h2>In conclusion</h2>
@@ -2156,7 +2165,7 @@ L<DBD::SQLite>, are not thread-safe.
 
 IRC:
 
-    Join #catalyst-talk on irc.perl.org.
+    Join #catalyst on irc.perl.org.
 
 Mailing Lists: