Catalyst-Runtime
view release on metacpan or search on metacpan
- silence warning and error output from tests
5.90120 - 2018-10-19
- avoid problematic test using sysread() on :utf8 filehandles on dev perl
versions where this is fatal (starting with 5.29.4). see RT#125843.
5.90119 - 2018-09-24
- fix test for changes in MooseX::Getopt 0.73 (RT#127050)
5.90118 - 2018-05-01
- fix handling of fragments in uri_for when path is an unblessed string (GH#160)
- ensure catalyst.pl is included with dist
- drop IO::Scalar prereq
- include optional test prereqs as develop prereqs
- remove unused developer prereq on Catalyst::Engine::PSGI
- use namespace::clean consistently rather than namespace::autoclean
- use JSON for test metadata to avoid needing YAML
- use JSON::MaybeXS consistently in code
- drop unused prereq of HTTP::Request::AsCGI
- drop unneeded prereq of Class::Data::Inheritable
- fix tests to cope with changes in new versions of Time::HiRes
- Document using namespace::autoclean with controllers that have actions
with type constraints.
- Look for type constraints in super classes and consumed roles.
- Change the way the stash middleware works to no longer localize $psgi_env.
- If you delegate control to a sub Catalyst application, that application
may now return information to the parent application via the stash.
- Fix for RT#106373 (Issue when you try to install and also have an old
version of Test::Mechanize::WWW::Catalyst)
5.90097 - 2015-07-28
- $c->uri_for now defines a final argument for setting the URL fragment
/URL anchor. This is now the canonical approach to setting a fragment
via uri_for.
- Reverted how we treat $c->uri_for($path) where $path is a string. When
we introduced the UTF-8 work we started encoding stringy paths, which
breaks code that did not expect that. We now consider stringy $path to
be 'expert' mode and you are expected to perform all nessary encoding.
5.90096 - 2015-07-27
- Fixed regression introduced in previous release that prevented a URI
fragment from getting properly encoded. Added more tests around this
to define behavior better.
5.90095 - 2015-07-27
- Minor test case tweak that I hope solve some minor hiesenfails reported
on CPAN testers.
- (https://github.com/perl-catalyst/catalyst-runtime/pull/109) added som
additional directions to how to setup a development sandbox
- (https://github.com/perl-catalyst/catalyst-runtime/pull/108) fix bug in
encoding where URI fragment seperator '#' in ->uri_for would get encoded.
5.90094 - 2015-07-24
- When there is a multipart POST request and the parts have extended
HTTP headers, try harder to decode and squeeze a meaningful value
out of it before giving up and crying. Updated docs and tests to
reflect this change. This should solve problems when your clients
are posting multipart form values with special character sets.
- Fixed issue where last_error actually returned the first error. Took
the change to add a 'pop_errors' to give the inverse of shift_errors.
- Merged Pull Requests:
lib/Catalyst.pm view on Meta::CPAN
## do stuff here..
};
=cut
sub setup_finalize {
my ($class) = @_;
$class->setup_finished(1);
}
=head2 $c->uri_for( $path?, @args?, \%query_values?, \$fragment? )
=head2 $c->uri_for( $action, \@captures?, @args?, \%query_values?, \$fragment? )
=head2 $c->uri_for( $action, [@captures, @args], \%query_values?, \$fragment? )
Constructs an absolute L<URI> object based on the application root, the
provided path, and the additional arguments and query parameters provided.
When used as a string, provides a textual URI. If you need more flexibility
than this (i.e. the option to provide relative URIs etc.) see
L<Catalyst::Plugin::SmartURI>.
If no arguments are provided, the URI for the current action is returned.
To return the current action and also provide @args, use
C<< $c->uri_for( $c->action, @args ) >>.
lib/Catalyst.pm view on Meta::CPAN
to C<< $c->namespace >> (if it doesn't begin with a forward slash) or
relative to the application root (if it does). It is then merged with
C<< $c->request->base >>; any C<@args> are appended as additional path
components; and any C<%query_values> are appended as C<?foo=bar> parameters.
B<NOTE> If you are using this 'stringy' first argument, we skip encoding and
allow you to declare something like:
$c->uri_for('/foo/bar#baz')
Where 'baz' is a URI fragment. We consider this first argument string to be
'expert' mode where you are expected to create a valid URL and we for the most
part just pass it through without a lot of internal effort to escape and encode.
If the first argument is a L<Catalyst::Action> it represents an action which
will have its path resolved using C<< $c->dispatcher->uri_for_action >>. The
optional C<\@captures> argument (an arrayref) allows passing the captured
variables that are needed to fill in the paths of Chained and Regex actions;
once the path is resolved, C<uri_for> continues as though a path was
provided, appending any arguments or parameters and creating an absolute
URI.
lib/Catalyst.pm view on Meta::CPAN
sub uri_for {
my ( $c, $path, @args ) = @_;
if ( $path->$_isa('Catalyst::Controller') ) {
$path = $path->path_prefix;
$path =~ s{/+\z}{};
$path .= '/';
}
my $fragment = ((scalar(@args) && ref($args[-1]) eq 'SCALAR') ? ${pop @args} : undef );
unless(blessed $path) {
if (defined($path) and $path =~ s/#(.+)$//) {
if(defined($1) and defined $fragment) {
carp "Abiguious fragment declaration: You cannot define a fragment in '$path' and as an argument '$fragment'";
}
if(defined($1)) {
$fragment = $1;
}
}
}
my $params =
( scalar @args && ref $args[$#args] eq 'HASH' ? pop @args : {} );
undef($path) if (defined $path && $path eq '');
carp "uri_for called with undef argument" if grep { ! defined $_ } @args;
lib/Catalyst.pm view on Meta::CPAN
"${key}=$param";
} ( ref $val eq 'ARRAY' ? @$val : $val ));
} @keys);
}
$base = encode_utf8 $base;
$base =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
$args = encode_utf8 $args;
$args =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
if(defined $fragment) {
if(blessed $path) {
$fragment = encode_utf8($fragment);
$fragment =~ s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go;
$fragment =~ s/ /+/g;
}
$query .= "#$fragment";
}
my $res = bless(\"${base}${args}${query}", $class);
$res;
}
=head2 $c->uri_for_action( $path, \@captures_and_args?, @args?, \%query_values? )
=head2 $c->uri_for_action( $action, \@captures_and_args?, @args?, \%query_values? )
lib/Catalyst/Delta.pod view on Meta::CPAN
the PSGI env hashref. This was done to fix bugs where people set PSGI ENV hash
keys and found them to disappear in certain cases. It also means that now if
a sub applications sets stash variables, that stash will now bubble up to the
parent application. This may be a breaking change for you since previous
versions of this code did not allow that. A workaround is to explicitly delete
stash keys in your sub application before returning control to the parent
application.
=head2 VERSION 5.90097
=head3 Defined how $c->uri_for adds a URI fragment.
We now have a specification for creating URIs with fragments (or HTML anchors).
Previously you could do this as a side effect of how we create URIs but this
side effect behavior was never documented or tested, and was broken when we
introduced default UTF-8 encoding. When creating URIs with fragments please
follow the new, supported specification:
$c->uri_for($action_or_path, \@captures_or_args, @args, \$query, \$fragment);
This will be a breaking change for some codebases, we recommend testing if
you are creating URLs with fragments.
B<NOTE> If you are using the alternative:
$c->uri_for('/foo/bar#baz')
construction, we do not attempt to encode this and it will make a URL with a
fragment of 'baz'.
=head2 VERSION 5.90094
=head3 Multipart form POST with character set headers
When we did the UTF8 work, we punted on Form POSTs when the POST envelope was
multipart and each part had complex headers such as content-types, character
sets and so forth. In those cases instead of returning a possibly incorrect
value, we returned an object describing the part so that you could figure it
out manually. This turned out to be a bad workaround as people did not expect
lib/Catalyst/Upgrading.pod view on Meta::CPAN
the PSGI env hashref. This was done to fix bugs where people set PSGI ENV hash
keys and found them to disappear in certain cases. It also means that now if
a sub applications sets stash variables, that stash will now bubble up to the
parent application. This may be a breaking change for you since previous
versions of this code did not allow that. A workaround is to explicitly delete
stash keys in your sub application before returning control to the parent
application.
=head1 Upgrading to Catalyst 5.90097
In older versions of Catalyst one could construct a L<URI> with a fragment (such as
https://localhost/foo/bar#fragment) by using a '#' in the path or final argument, for
example:
$c->uri_for($action, 'foo#fragment');
This behavior was never documented and would break if using the Unicode plugin, or when
adding a query to the arguments:
$c->uri_for($action, 'foo#fragment', +{ a=>1, b=>2});
would define a fragment like "#fragment?a=1&b=2".
When we introduced UTF-8 encoding by default in Catalyst 5.9008x this side effect behavior
was broken since we started encoding the '#' when it was part of the URI path.
In version 5.90095 and 5.90096 we attempted to fix this, but all we managed to do was break
people with URIs that included '#' as part of the path data, when it was not expected to
be a fragment delimiter.
In general L<Catalyst> prefers an explicit specification rather than relying on side effects
or domain specific mini languages. As a result we are now defining how to set a fragment
for a URI via ->uri_for:
$c->uri_for($action_or_path, \@captures_or_args, @args, \$query, \$fragment);
If you are relying on the previous side effect behavior your URLs will now encode the '#'
delimiter, which is going to be a breaking change for you. You need to alter your code
to match the new specification or modify uri_for for your local case. Patches to solve
this are very welcomed, as long as they don't break existing test cases.
B<NOTE> If you are using the string form of the first argument:
$c->uri_for('/foo/bar#baz')
construction, we do not attempt to encode this and it will make a URL with a
fragment of 'baz'.
=head1 Upgrading to Catalyst 5.90095
The method C<last_error> in L</Catalyst> was actually returning the first error. This has
been fixed but there is a small chance it could be a breaking issue for you. If this gives
you trouble changing to C<shift_errors> is the easiest workaround (although that does
modify the error stack so if you are relying on that not being changed you should try something
like @{$c->errors}[-1] instead. Since this method is relatively new and the cases when the
error stack actually has more than one error in it, we feel the exposure is very low, but bug
t/aggregate/unit_core_uri_for.t view on Meta::CPAN
'Plus is not encoded'
);
is(
Catalyst::uri_for( $context, '/bar', 'with space', { 'also with' => 'space here' })->as_string,
'http://127.0.0.1/foo/bar/with%20space?also+with=space+here',
'Spaces encoded correctly'
);
is(
Catalyst::uri_for( $context, '/bar#fragment', { param1 => 'value1' } )->as_string,
'http://127.0.0.1/foo/bar?param1=value1#fragment',
'URI for path with fragment and query params 1'
);
is(
Catalyst::uri_for( $context, '/bar', { param1 => 'value1' }, \'fragment' )->as_string,
'http://127.0.0.1/foo/bar?param1=value1#fragment',
'URI for path with fragment and query params 1'
);
is(
Catalyst::uri_for( $context, '0#fragment', { param1 => 'value1' } )->as_string,
'http://127.0.0.1/foo/yada/0?param1=value1#fragment',
'URI for path 0 with fragment and query params 1'
);
is(
Catalyst::uri_for( $context, '/bar#fragment^%$', { param1 => 'value1' } )->as_string,
'http://127.0.0.1/foo/bar?param1=value1#fragment^%$',
'URI for path with fragment and query params 3'
);
is(
Catalyst::uri_for( $context, '/foo#bar/baz', { param1 => 'value1' } )->as_string,
'http://127.0.0.1/foo/foo?param1=value1#bar/baz',
'URI for path with fragment and query params 3'
);
is(
Catalyst::uri_for( 'TestApp', '/bar/baz' )->as_string,
'/bar/baz',
'URI for absolute path, called with only class name'
);
## relative action (or path) doesn't make sense when calling as class method
# is(
t/aggregate/unit_core_uri_for.t view on Meta::CPAN
is(
Catalyst::uri_for( 'TestApp', '/bar', 'with space', { 'also with' => 'space here' })->as_string,
'/bar/with%20space?also+with=space+here',
'Spaces encoded correctly, called with only class name'
);
TODO: {
local $TODO = 'broken by 5.7008';
is(
Catalyst::uri_for( $context, '/bar#fragment', { param1 => 'value1' } )->as_string,
'http://127.0.0.1/foo/bar?param1=value1#fragment',
'URI for path with fragment and query params'
);
}
# test with utf-8
is(
Catalyst::uri_for( $context, 'quux', { param1 => "\x{2620}" } )->as_string,
'http://127.0.0.1/foo/yada/quux?param1=%E2%98%A0',
'URI for undef action with query params in unicode'
);
is(
t/aggregate/unit_core_uri_for.t view on Meta::CPAN
use overload '""' => sub { $_[0]->{string} }, fallback => 1;
}
is(
Catalyst::uri_for( $context, bless( { string => 'test' }, 'MyStringThing' ) ),
'http://127.0.0.1/test',
'overloaded object handled correctly'
);
is(
Catalyst::uri_for( $context, bless( { string => 'test' }, 'MyStringThing' ), \'fragment' ),
'http://127.0.0.1/test#fragment',
'overloaded object handled correctly'
);
done_testing;
( run in 0.972 second using v1.01-cache-2.11-cpan-364913b4093 )