Merge 'trunk' into 'uri_for_utf8'
Tomas Doran [Mon, 8 Feb 2010 20:58:18 +0000 (20:58 +0000)]
r12570@t0mlaptop (orig r12535):  rafl | 2010-01-06 15:59:41 +0000
Clarify comment.
r12589@t0mlaptop (orig r12554):  t0m | 2010-01-09 15:37:00 +0000
Don't screw over people using --detach, <sigh>
r12590@t0mlaptop (orig r12555):  t0m | 2010-01-09 15:57:27 +0000
Back out r12493, use \Q instead
r12591@t0mlaptop (orig r12556):  t0m | 2010-01-09 15:58:18 +0000
Changelog Adopt::NEXT warnings
r12592@t0mlaptop (orig r12557):  t0m | 2010-01-09 16:43:25 +0000
Correctly pass argv option into Catalyst::Engine::HTTP
r12593@t0mlaptop (orig r12558):  t0m | 2010-01-09 16:54:08 +0000
Un stupid
r12594@t0mlaptop (orig r12559):  t0m | 2010-01-09 17:38:59 +0000
Bump dep
r12608@t0mlaptop (orig r12573):  t0m | 2010-01-09 18:22:02 +0000
Bump version of ::Role::WithOverloading
r12610@t0mlaptop (orig r12575):  t0m | 2010-01-09 19:01:59 +0000
require autoclean once only
r12622@t0mlaptop (orig r12587):  rafl | 2010-01-10 02:00:03 +0000
Version 5.80017.
r12631@t0mlaptop (orig r12596):  t0m | 2010-01-10 14:22:15 +0000
Apply patch to clarify uri_for action from Octavian Rasnita on list
r12640@t0mlaptop (orig r12605):  t0m | 2010-01-11 21:11:05 +0000
Deprecate bare imports of Catalyst::Test - either use an app name or don't run the import method. As-per r12564
r12648@t0mlaptop (orig r12613):  t0m | 2010-01-11 23:18:08 +0000
Fix URI bug masked by HTTP::Request::AsCGI
r12652@t0mlaptop (orig r12617):  rafl | 2010-01-12 21:37:31 +0000
Fix a deprecation warning in the tests.
r12653@t0mlaptop (orig r12618):  rafl | 2010-01-12 21:37:39 +0000
canonical() is a no-op for the base uri.
r12654@t0mlaptop (orig r12619):  rafl | 2010-01-12 21:37:46 +0000
Version 5.80018.
r12669@t0mlaptop (orig r12634):  rafl | 2010-01-14 02:26:03 +0000
Depend on n:c 0.12 to work on perl >= 5.11.2.
r12673@t0mlaptop (orig r12638):  rafl | 2010-01-14 05:21:24 +0000
Exception stuff is fixed for a while now.
r12674@t0mlaptop (orig r12639):  rafl | 2010-01-14 05:45:09 +0000
Only set up the leakchecker for the tests that need it.

That way we avoid the useless Devel::Cycle glob warnings.
r12676@t0mlaptop (orig r12641):  dandv | 2010-01-14 08:15:10 +0000
Typo fix
r12678@t0mlaptop (orig r12643):  dandv | 2010-01-14 09:23:50 +0000
Cosmetic: wrapped long code line
r12690@t0mlaptop (orig r12655):  dandv | 2010-01-14 23:52:44 +0000
Passing test case for RT #53678 - Catalyst::Test::get currently doesn't decode the response body octets

r12691@t0mlaptop (orig r12656):  karpet | 2010-01-15 06:35:30 +0000
in what case is a numeric comparison called for? I cannot think of one. Is this the best way to test?
r12698@t0mlaptop (orig r12663):  t0m | 2010-01-15 16:39:55 +0000
Clarify that it's an app, not a ctx here
r12713@t0mlaptop (orig r12678):  rafl | 2010-01-18 09:00:20 +0000
Depend on a namespace::clean that isn't broken on <= 5.8.8.
r12725@t0mlaptop (orig r12690):  rafl | 2010-01-19 16:07:45 +0000
Merge branch 'action_args'

* action_args:
  And another minor tweak.
  Some more doc tweaking.
  tweaked docs based on IRC suggestions
  added documentation for the configuration option "action_args".
  Allow passing extra args to action constructors using action_args config.
  Add tests for passing extra arguments to action constructors.
  Create branch action_args
r12726@t0mlaptop (orig r12691):  rafl | 2010-01-19 16:08:22 +0000
Changelog action_args.
r12728@t0mlaptop (orig r12693):  aristotle | 2010-01-19 21:41:23 +0000
fix $c->error doc in Catalyst.pm POD
r12761@t0mlaptop (orig r12726):  aCiD2 | 2010-01-25 01:03:52 +0000
Improve the documentation about -Home and how Catalyst finds the home path for apps
r12762@t0mlaptop (orig r12727):  rafl | 2010-01-25 18:59:52 +0000
Revert "in what case is a numeric comparison called for? I cannot think of one. Is this the best way to test?"

This reverts commit 279b2f1abb0a8e056b8c905e5a4ecb66537ee194.
r12763@t0mlaptop (orig r12728):  rafl | 2010-01-25 19:00:17 +0000
Remove apparently useless Component::BUILDARGS conditional.
r12778@t0mlaptop (orig r12743):  t0m | 2010-01-27 20:12:46 +0000
Clarrify debug documentation
r12779@t0mlaptop (orig r12744):  t0m | 2010-01-27 20:15:52 +0000
Fix failing test related to missing g in regex
r12781@t0mlaptop (orig r12746):  t0m | 2010-01-27 21:04:17 +0000
Fix / => %2F in uri_for so that it only works for action objects as previously advertised as this has been screwing people. Also fix multiple / => %2F conversion in the same arg/capture
r12793@t0mlaptop (orig r12758):  t0m | 2010-01-28 15:47:31 +0000
Fix paths with URI encoding as the first path part
r12794@t0mlaptop (orig r12759):  t0m | 2010-01-28 18:15:10 +0000
And test the non root app case
r12804@t0mlaptop (orig r12769):  t0m | 2010-01-28 23:28:15 +0000
Changelog up to date
r12805@t0mlaptop (orig r12770):  rafl | 2010-01-29 00:16:42 +0000
Changelog tweaking.
r12806@t0mlaptop (orig r12771):  rafl | 2010-01-29 00:16:48 +0000
Version 5.80019.
r12845@t0mlaptop (orig r12810):  rafl | 2010-02-04 05:50:05 +0000
Merge branch 'expand_modules'

* expand_modules:
  Allow models and components to specify the names of any components they generate
  Branching to allow components to specify any modules they may have created
r12846@t0mlaptop (orig r12811):  rafl | 2010-02-04 06:18:46 +0000
Version 5.80020.

lib/Catalyst.pm
t/aggregate/live_component_controller_action_chained.t
t/aggregate/unit_core_uri_for_multibytechar.t

index 25f4caf..495a715 100644 (file)
@@ -1275,6 +1275,12 @@ sub uri_for {
                         ( scalar @args && ref $args[0] eq 'ARRAY'
                          ? @{ shift(@args) }
                          : ()) ];
+
+        foreach my $capture (@$captures) {
+            utf8::encode($capture) if utf8::is_utf8($capture);
+            $capture =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
+        }
+
         my $action = $path;
         $path = $c->dispatcher->uri_for_action($action, $captures);
         if (not defined $path) {
@@ -1285,6 +1291,19 @@ sub uri_for {
         $path = '/' if $path eq '';
     }
 
+    undef($path) if (defined $path && $path eq '');
+
+    my $params =
+      ( scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {} );
+
+    carp "uri_for called with undef argument" if grep { ! defined $_ } @args;
+
+    foreach my $arg (@args) {
+        utf8::encode($arg) if utf8::is_utf8($arg);
+    }
+    s/([^$URI::uric])/$URI::Escape::escapes{$1}/go for @args;
+    s|/|%2F| for @args;
+
     unshift(@args, $path);
 
     unless (defined $path && $path =~ s!^/!!) { # in-place strip
@@ -1316,7 +1335,6 @@ sub uri_for {
           (map {
               my $param = "$_";
               utf8::encode( $param ) if utf8::is_utf8($param);
-              # using the URI::Escape pattern here so utf8 chars survive
               $param =~ s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go;
               $param =~ s/ /+/g;
               "${key}=$param"; } ( ref $val eq 'ARRAY' ? @$val : $val ));
index b0be898..7977875 100644 (file)
@@ -1074,6 +1074,7 @@ sub run_tests {
         ['foo%2Fbar', 'baz%2Fquux'],
         ['foo%2Fbar', 'baz%2Fquux', { foo => 'bar', 'baz' => 'quux%2Ffrood'}],
         ['foo%2Fbar', 'baz%2Fquux', { foo => 'bar', 'baz%2Ffnoo' => 'quux%2Ffrood'}],
+        ['h%C3%BCtte', 'h%C3%BCtte', { test => 'h%C3%BCtte' } ],
     ) {
         my $path = '/chained/roundtrip_urifor/' .
             $thing->[0] . '/' . $thing->[1];
index 3320491..6f5d8ae 100644 (file)
@@ -1,10 +1,9 @@
 use strict;
 use warnings;
-
 use FindBin;
 use lib "$FindBin::Bin/../lib";
 
-use Test::More tests => 5;
+use Test::More;
 
 use_ok('TestApp');
 
@@ -33,3 +32,19 @@ is($context->req->uri_with({ name => '村瀬大輔' }), $uri_with_multibyte, 'ur
 # multibyte with utf8 string
 is($context->uri_for('/', { name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_for with utf8 string query');
 is($context->req->uri_with({ name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_with with utf8 string query');
+
+# multibyte captures and args
+my $action = $context->controller('Action::Chained')
+    ->action_for('roundtrip_urifor_end');
+
+{
+use utf8;
+
+is($context->uri_for($action, ['hütte'], 'hütte', {
+    test => 'hütte'
+}),
+'http://127.0.0.1/chained/roundtrip_urifor/h%C3%BCtte/h%C3%BCtte?test=h%C3%BCtte',
+'uri_for with utf8 captures and args');
+}
+
+done_testing;