# This file documents the revision history for Perl extension Catalyst.
+5.80019 2010-01-29 01:04:09
+
+ Bug fixed:
+ - Calls to $c->uri_for with private paths as strings (e.g.
+ $c->uri_for('controller/action', 'arg1', 'arg2') ) no longer have
+ / encoded to %2F. This is due to $c->uri_for('static', 'css/foo', $bar)
+ which should not be encoded.
+ Calls with an action object (rather than a string), or uri_for action
+ will still encode / in args and captures to %2F
+
+ - The above noted / => %2F encoding in uri_for_action or uri_for with
+ an action object has been fixed to not just encode the first slash in
+ any set of args/captures.
+
+ - nginx and lighttpd FCGI requests with URI encoded sections as the first
+ path part have been fixed to operate correctly.
+
+ - A source of bogus warnings in Catalyst::Component::BUILDARGS has been
+ removed.
+
+ Documentation:
+ - Improve the documentation about -Home and how Catalyst finds the home path
+ for applications.
+ - Various minor typo fixes.
+
New features:
- Allow passing additional arguments to action constructors.
Documentation:
- Clarify that uri_for_action works on private paths, with example.
+ - Clarify documentation about debug
Deprecations:
- Saying use Catalyst::Test; (without an application name or () to stop
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.80018';
+our $VERSION = '5.80019';
$VERSION = eval $VERSION;
sub import {
settings override the application, with <MYAPP>_DEBUG having the highest
priority.
+This sets the log level to 'debug' and enables full debug output on the
+error screen. If you only want the latter, see L<< $c->debug >>.
+
=head2 -Engine
Forces Catalyst to use a specific engine. Omit the
the name will be replaced with underscores, e.g. MyApp::Web should use
MYAPP_WEB_HOME. If both variables are set, the MYAPP_HOME one will be used.
+If none of these are set, Catalyst will attempt to automatically detect the
+home directory. If you are working in a development envirnoment, Catalyst
+will try and find the directory containing either Makefile.PL, Build.PL or
+dist.ini. If the application has been installed into the system (i.e.
+you have done C<make install>), then Catalyst will use the path to your
+application module, without the .pm extension (ie, /foo/MyApp if your
+application was installed at /foo/MyApp.pm)
+
=head2 -Log
use Catalyst '-Log=warn,fatal,error';
=back
+The first three also set the log level to 'debug'.
+
Calling C<< $c->debug(1) >> has no effect.
=cut
$path .= '/';
}
+ 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;
+ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go for @args;
+ if (blessed $path) { # Action object only.
+ s|/|%2F|g for @args;
+ }
+
if ( blessed($path) ) { # action object
- my $captures = [ map { s|/|%2F|; $_; }
+ my $captures = [ map { s|/|%2F|g; $_; }
( scalar @args && ref $args[0] eq 'ARRAY'
? @{ shift(@args) }
: ()) ];
$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;
- 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
} elsif (Class::MOP::is_class_loaded($_[0]) &&
$_[0]->isa('Catalyst') && ref($_[1]) eq 'HASH') {
$args = $_[1];
- } elsif ($_[0] eq $_[1]) {
- $args = $_[1];
} else {
$args = +{ @_ };
}
if (substr($req_uri, 0, 1) ne '/') {
my ($match) = $req_uri =~ m|^([^/]+)|;
my ($path_info_part) = $path_info =~ m|^(.*?\Q$match\E)|;
- substr($req_uri, 0, length($match), $path_info_part);
+ substr($req_uri, 0, length($match), $path_info_part)
+ if $path_info_part;
}
$path_info = $req_uri;
}
# Remember to update this in Catalyst as well!
-our $VERSION='5.80018';
+our $VERSION='5.80019';
$VERSION = eval $VERSION;
'request ' . $path . ' ok');
# Just check that the path matches, as who the hell knows or cares
# where the app is based (live tests etc)
- ok( index($content, $path) > 1, 'uri can round trip through uri_for' );
+ ok( index($content, $path) > 1, 'uri can round trip through uri_for' )
+ or diag("Expected $path, got $content");
}
}
-use Test::More tests => 23;
+use Test::More tests => 22;
use strict;
use warnings;
is_deeply($args, [qw/foo3 bar3/], 'args passed to ACCEPT_CONTEXT ok');
}
-# BUILDARGS logic
-{
- {
- package MyController;
- @MyController::ISA = ('Catalyst::Controller');
- }
- my $warning;
- local $SIG{__WARN__} = sub {
- $warning = shift;
- diag($warning);
- };
- my $controller = MyController->new('MyApp', undef);
- like( $warning, qr/uninitialized value in string eq/, "no warning for == comparison");
-
-}
is ''.$r->base, 'http://www.foo.com/';
}
+# nginx example from espent with path /"foo"
+{
+ my $r = get_req (
+ PATH_INFO => '"foo"',
+ SCRIPT_NAME => '/',
+ REQUEST_URI => '/%22foo%22',
+ );
+ is ''.$r->path, '%22foo%22';
+ is ''.$r->uri, 'http://www.foo.com/%22foo%22';
+ is ''.$r->base, 'http://www.foo.com/';
+}
+
+# nginx example from espent with path /"foo" and the app based at /oslobilder
+{
+ my $r = get_req (
+ PATH_INFO => 'oslobilder/"foo"',
+ SCRIPT_NAME => '/oslobilder/',
+ REQUEST_URI => '/oslobilder/%22foo%22',
+ );
+ is ''.$r->path, '%22foo%22';
+ is ''.$r->uri, 'http://www.foo.com/oslobilder/%22foo%22';
+ is ''.$r->base, 'http://www.foo.com/oslobilder/';
+}
+
+
# FIXME - Test proxy logic
use strict;
use warnings;
-
-use Test::More tests => 20;
+use FindBin qw/$Bin/;
+use lib "$FindBin::Bin/../lib";
+use Test::More;
use URI;
-use_ok('Catalyst');
+use_ok('TestApp');
my $request = Catalyst::Request->new( {
base => URI->new('http://127.0.0.1/foo')
} );
-
-my $context = Catalyst->new( {
+my $dispatcher = TestApp->dispatcher;
+my $context = TestApp->new( {
request => $request,
namespace => 'yada',
} );
is_deeply($query_params_base, $query_params_test,
"uri_for() doesn't mess up query parameter hash in the caller");
}
+
+
+{
+ my $path_action = $dispatcher->get_action_by_path(
+ '/action/path/six'
+ );
+
+ # 5.80018 is only encoding the first of the / in the arg.
+ is(
+ Catalyst::uri_for( $context, $path_action, 'foo/bar/baz' )->as_string,
+ 'http://127.0.0.1/action/path/six/foo%2Fbar%2Fbaz',
+ 'Escape all forward slashes in args as %2F'
+ );
+}
+
+
+done_testing;
+