merged
John Napiorkowski [Thu, 29 Oct 2015 15:13:48 +0000 (10:13 -0500)]
1  2 
Changes
lib/Catalyst.pm
t/aggregate/unit_core_uri_for.t

diff --cc Changes
+++ b/Changes
  # This file documents the revision history for Perl extension Catalyst.
  
 +5.90102 - 2015-10-29
 +  - Better warnings when there's an error reading the psgi.input (billmosley++)
 +  - Fixed spurious warnings in uri_for when using no arguments (melmothx++ and 
 +    paultcochrane++)
 +  - Documentation improvements (paultcochrane++)
++  - Improvements to 'search_extra' configuration and tests around using 
++    uri_for as a class method (cngarrison++)
 +
 +5.90101 - 2015-09-04
 +  - Fixed a regression introduced in the last release which caused test
 +    case failure when using a version of Perl 5.14 or older.
 +
 +5.90100 - 2015-08-24
 +  - 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:
 +    - https://github.com/perl-catalyst/catalyst-runtime/pull/95
 +    - https://github.com/perl-catalyst/catalyst-runtime/pull/96
 +    - https://github.com/perl-catalyst/catalyst-runtime/pull/97
 +    - https://github.com/perl-catalyst/catalyst-runtime/pull/98
 +    - https://github.com/perl-catalyst/catalyst-runtime/pull/106
 +    - https://github.com/perl-catalyst/catalyst-runtime/pull/107
 +
 +5.90093 - 2015-05-29
 +  - Fixed a bug where if you used $res->write and then $res->body, the
 +    contents of body would be double encoded (gshank++).
 +
 +5.90092 - 2015-05-19
 +  - Allows you to use a namespace suffix for request, response and stats
 +    class traits.  Docs and tests for this.
 +  - Refactor the change introduced in 5.90091 to solve reported issues (for
 +    example Catalyst::Controller::DBIC::API fails its tests) and to be a more
 +    conservative refactor (new code more closely resembles the orginal code
 +    that has proven to work for years.)
 +
 +5.90091 - 2015-05-08
 +  - Fixed a bug where if an injected component expanded sub components, those
 +    sub components would not show up in the startup debug dev console (
 +    even though they were actually created).
 +
 +5.90090 - 2015-04-29
 +  - Updated some documention in Catalyst::Request::Upload to clarify behavior
 +    that RT ticket reported as confusing or unexpected
 +  - Merged all changes from 5.90089_XXX development cycle.
 +  - removed a mistaken use of Test::Most, which is not a core Catalyst
 +    dependency.  Used Test::More instead.
 +
 +5.90089_004 - 2015-04-28
 +  - Added swanky github badges.
 +  - Reverted a change to how the stats engine is setup that was incorrect.
 +  - New application setup hook 'config_for' which allows one to get the
 +    canonical application configuration for a controller, view or model, or
 +    a plugin.  Can also be used to override and adapt what configuration is
 +    retrieved.
 +
 +5.90089_003 - 2015-04-27
 +  - Fixed an issue where a delayed controller that did ACCEPT_CONTEXT would
 +    raise an error when registering its actions.
 +  - Updated some documentation around route matching.
 +  - refactored the setup of injected components to allow you to hook into
 +    the injection and do custom injection types.
 +
 +5.90089_002 - 2015-04-17
 +  - Changed the way we check for presence of Type::Tiny in a test case to be
 +    more explicit in the version requirement.  Hopefully a fix for reported
 +    test fail.
 +  - When declaring type constraints in Args and CaptureArgs, if you want to
 +    use a Moose builtin type (or a custom stringy type that you've already
 +    defined and associated with the Moose::TypeRegistry) you must now quote
 +    the type name.  This is to clearly disambiguate between Moose stringy types
 +    and imported types.
 +  - Additional changes to type constraint detection to between determine when a
 +    type constraint for reference types have a measured number of arguments or
 +    not.  clarify restriction on reference type constraints.
 +  - Several bugs with type constraints and uri_for squashed.  More test cases
 +    around all the argument type constraints to tighten scope of action.
 +  - NEW FEATURE: New method in Catalyst::Utils 'inject_component', which is a core
 +    version of the previously external addon 'CatalystX::InjectComponent'.  You should
 +    start to convert your existing code which uses the stand alone version, since
 +    going forward only the core version will be supported.  Also the core version in
 +    Catalyst::Utils has an additional feature to compose roles into the injected
 +    component.
 +  - NEW FEATURE: Concepts from 'CatalystX::RoleApplicator' have been moved to core
 +    so we now have the follow application attributes 'request_class_traits',
 +    'response_class_traits' and 'stats_class_traits' which allow you to compose
 +    traits for these core Catalyst classes without needing to create subclasses. So
 +    in general any request or response trait on CPAN that used 'CatalystX::RoleApplicator'
 +    should now just work with this core feature.  Note that  can also set thse roles
 +    via new configuration keys, 'request_class_traits', 'response_class_traits' 
 +    and 'stats_class_traits'. If you use both configuration and application class methods,
 +    they are combined.
 +  - NEW FEATURE: Core concepts from 'CatalystX::ComponentsFromConfig'.  You can now
 +    setup components directly from configuration.  This could save you some effort and
 +    creating 'empty' base classes in your Model/View and Controller directories.  This
 +    feature is currently limited in that you can only configure components that are
 +    'true' Catalyst components (but you may use Catalyst::Model::Adaptor to proxy
 +    stand alone classes...).
 +  - Only create a stats object if you are using stats.  This is a minor performance
 +    optimization, but there's a small chance it is a breaking change, so please
 +    report any stats related issues.
 +  - Added a developer mode warning if you call a component with arguments that does not
 +    expect arguments (for example calling $c->model('Foo', 1,2,3,4) where Myapp::Model::Foo
 +    does not ACCEPT_CONTEXT.  Only components that ACCEPT_CONTEXT do anything with
 +    passed arguments in $c->controller/view/model.
 +  - Change the way components are setup so that you can now rely on all components
 +    when setting up a component.  Previously application scoped components could not
 +    reliably use an existing application scoped component as a dependecy for initialization.
 +
 +5.90089_001 - 2015-03-26
 +  - New development branch synched with 5.90085.
 +  - NEW FEATURE: Type Constraints on Args/CaptureArgs.  Allows you to declare
 +    a Moose, MooseX::Types or Type::Tiny named constraint on your Arg or 
 +    CaptureArg.
 +  - When using $c->uri_for (or the derived $c->uri_for_action) and the target
 +    action has type constrainted args (or captures), verify that the proposed
 +    URL matches the defined args.  In general $c->uri_for will be a bit more
 +    noisy if the supplied arguments are not correct.
 +  - New top level document on Route matching. (Catalyst::RouteMatching).  This
 +    document is still in development, but is worth review and comments.
 +
 +5.90085 - 2015-03-25
 +  - Small change to Catalyst::Action to prevent autovivication of Args value (dim1++)
 +  - Minor typo fixes (Abraxxa++)
 +  - Make sure than when using chained actions and when more than one action
 +    matches the same path specification AND has Args(0), that we follow the
 +    "in a tie, the last action defined wins" rule.  There is a small chance
 +    this is a breaking change for you.  See Catalyst::Upgrading for more.
 +    You may use the application configuration setting "use_chained_args_0_special_case"
 +    to disable this new behavior, if you must for back-compat reasons.
 +  - Added PATCH HTTP Method action attribute shortcut.
 +  - Several new configuration options aimed to give improved backwards compatibility
 +    for when your URL query parameters or keywords have non UTF-8 encodings.
 +    See Catalyst::Upgrading.
 +
 +5.90084 - 2015-02-23
 +  - Small change to the way body parameters are created in order to prevent
 +    trying to create parameters twice.
 +  - Use new HTTP::Body and code updates to fix issue when POSTed params have
 +    non UTF-8 charset encodings or otherwise complex upload parts that are not
 +    file uploads. In these cases when Catalyst can't determine what the value of
 +    a form upload is, will return an instance of Catalyst::Request::PartData with
 +    all the information need to figure it out.  Documentation about this corner
 +    case. For RT https://rt.cpan.org/Ticket/Display.html?id=101556
 +  - Two new application configuration parameters 'skip_body_param_unicode_decoding'
 +    and 'skip_complex_post_part_handling' to assist you with any backward
 +    compatibility issues with all the new UTF8 work in the most recent stable
 +    Catalyst.  You may use these settings to TEMPORARILY disable certain new
 +    features while you are seeking a long term fix.
 +
 +5.90083 - 2015-02-16
 +  - Fixed typo in support for OPTIONS method matching (andre++)
 +  - Stop using $env->{'plack.request.query'} as a query parsing optimization
 +    since 1) it doesn't belong to us and 2) there's subtle differences in the
 +    way plack parses parameters and catalyst does.  This fixes a bug when you
 +    are using middleware that uses Plack::Request to do its thing.  This change
 +    might have subtle impact on query parsing.  Please test this change!
 +
 +5.90082 - 2015-01-10
 +  - Fixed a regression created in $response->from_psgi_response and test case
 +    to prevent it happening again.
 +
 +5.90081 - 2015-01-10
 +  - created class attribute 'finalized_default_middleware' which determines
 +    if the default middleware has been added to the stack yet or not.  This
 +    removes a horrible hack that polluted the configuration hash.  Added
 +    test case to prevent regressions.
 +
 +5.90080 - 2015-01-09
 +  - Minor documentation corrections
 +  - Make the '79 development series stable
 +
 +5.90079_008  - 2015-01-07
 +  - If we get a response set from $res->from_psgi_response and that response
 +    has a charset for the content type, we clear encoding for the rest of the
 +    response (avoid double encoding).  Added more documentation around this.
 +  - Documentation updates and typo fixes across various UTF8 docs (Mark Ellis++)
 +
 +5.90079_007  - 2015-01-07
 +  - Merged from Stable (5.90079)
 +  - reviewed and cleaned up UTF8 related docs
 +  - replace missing utf8 pragma in Catalyst::Engine
 +  - Cleaned up spelling errors in various docs (abbraxxa++)
 +  - New document Catalyst::UTF8 which attempts to summarize UTF8 and encoding
 +    changes introduced in v5.90080.
 +
 +5.90079_006  - 2015-01-02
 +  - Removed unneeded dependency on RenderView in new test case that was causing fails
 +    on CPAN testers that did not just happen to have that dependency already installed
 +  - Updated copyright notices to 2015
 +  - Documentation patches around the setup methods and clarification on on security
 +    note posted a few months ago.
 +  - Added my name to the contributors list
 +
 +5.90079_005 - 2014-12-31
 +  - Merged changes from 5.90078
 +  - If configuration 'using_frontend_proxy' is set, we add the correct middleware
 +    to the default middleware list.  This way you get the correct and expected
 +    behavior if you are starting your application via one of the generated scripts
 +    or if you are calling MyApp->psgi_app.  Previously if you started the application
 +    with ->psgi_app (or to_app) we ignored this configuration option
 +  - New configuration option 'using_frontend_proxy_path' which enables
 +    Plack::Middleware::ReverseProxyPath on your application easily.  Please note that
 +    Plack::Middleware::ReverseProxyPath is not an automatic dependency of Catalyst at
 +    this time, so if you want this feature you should add it to your project dependency
 +    list.  This is done to avoid continued growth of Catalyst dependencies.
 +  - Tweaks encoding docs a bit to get closer to final.
 +
 +5.90079_004 - 2014-12-26
 +  - Starting adding some docs around the new encoding stuff
 +  - Exposed the reqexp we use to match content types that need encoding via a
 +    global variable.
 +  - Added some test cases for JSON utf8 and tested file uploads with utf8.
 +  - Fixes to decoding on file upload filenames and related methods
 +  - new methods on upload object that tries to do the right thing if we find
 +    a character set on the upload and its UTF8.
 +  - new additional helper methods on the file upload object.
 +  - new helper methods has_encoding and clear_encoding on context.
 +  - Method on Catalyst::Response to determine if the response should be encoded.
 +  - Warn if changing headers only if headers are finalized AND the response callback
 +    has already been called (and headers already sent).
 +  - Centralized rules about detecting if we need to automatically encode or not and
 +    added tests around cases when you choose to skip auto encoding.
 +
 +5.90079_003 - 2014-12-03
 +  - Make sure all tests run even if debug mode is enabled.
 +  - Fixed issue with middleware stash test case that failed on older Perls
 +
 +5.90079_002 - 2014-12-02
 +  - Fixed typo in Makefile.PL which borked the previous distribution. No other
 +    changes.
 +
 +5.90079_001 - 2014-12-02
 +  - MyApp->to_app is now an alias for MyApp->psgi_app in order to better support
 +    existing Plack conventions.
 +  - Modify Catalyst::Response->from_psgi_response to allow the first argument to
 +    be an object that does ->as_psgi.
 +  - Modified Catalyst::Middleware::Stash to be a shallow copy in $env.  Added some
 +    docs.  Added a test case to make sure stash keys added in a child application
 +    don't bubble back up to the main application.
 +  - We no longer use Encode::is_utf8 since it doesn't work the way we think it
 +    does... This required some UTF-8 changes.  If your application is UTF-8 aware
 +    I highly suggest you test this release.
 +  - We always do utf8 decoding on incoming URLs (before we only did so if the server
 +    encoding was utf8.  I believe this is correct as per the w3c spec, but please
 +    correct if incorrect :)
 +  - Debug output now shows utf8 characters if those are incoming via Args or as
 +    path or pathparts in your actions.  query and body parameter keys are now also
 +    subject to utf8 decoding (or as specified via the encoding configuration value).
 +  - lots of UTF8 changes.  Again we think this is now more correct but please test.
 +  - Allow $c->res->redirect($url) to accept $url as an object that does ->as_string
 +    which I think will ease a common case (and common bug) and added documentation.
 +  - !!! UTF-8 is now the default encoding (there used to be none...).  You can disable
 +    this if you need to with MyApp->config(encoding => undef) if it causes you trouble.
 +  - Calling $c->res->write($data) now encodes $data based on the configured encoding
 +    (UTF-8 is default).
 +  - $c->res->writer_fh now returns Catalyst::Response::Writer which is a decorator
 +    over the PSGI writer and provides an additional method 'write_encoded' that just
 +    does the right thing for encoding your responses.  This is probably the method
 +    you want to use.
 +  - New dispatch matching attribute: Scheme.  This lets you match a route based on
 +    the incoming URI scheme (http, https, ws, wss).
 +  - If $c->uri_for targets an action or action chain that defines Scheme, use that
 +    scheme for the generated URI object instead of just using whatever the incoming
 +    request uses.
 +
 +5.90079 - 2015-01-02
 +  - Removed dependency from test case that we don't install for testing (
 +    rt #101243)
 +  - updated year in copyright notices
 +
 +5.90078 - 2014-12-30
 +  - POD corrections (sergey++)
 +  - New configuration option to disable the HTTP Exception passthrough feature
 +    introduced in 5.90060.  You can use this if that feature is causing you
 +    trouble. (davewood++);
 +  - Some additional helper methods for dealing with errors.
 +  - More clear exception when $request->body_data tries to parse malformed POSTed
 +    data.  Added documentation and tests around this.
 +
 +5.90077 - 2014-11-18
 +  - We store the PSGI $env in Catalyst::Engine for backcompat reasons.  Changed
 +    this so that the storage is a weak reference, so that it goes out of scope
 +    with the request.  This solves an issue where items in the stash (now in the
 +    PSGI env) would not get closed at the end of the request.  This caused some
 +    regression, primarily in custom testing classes.
 +
 +5.90076 - 2014-11-13
 +  - If throwing an exception object that does the code method, make sure that
 +    method returns an expected HTTP status code before passing it on to the
 +    HTTP Exception middleware.
 +
 +5.90075 - 2014-10-06
 +  - Documentation patch for $c->req->param to point out the recently discovered
 +    potential security issues: http://blog.gerv.net/2014/10/new-class-of-vulnerability-in-perl-web-applications/
 +  - You don't need to install this update, but you should read about the exploit
 +    and review if your code is vulnerable.  If you use the $c->req->param interface
 +    you really need to review this exploit.
 +
 +5.90074 - 2014-10-01
 +  - Specify Carp minimum version to avoid pointless test fails (valy++)
 +
  5.90073 - 2014-09-23
    - Fixed a regression caused by the last release where we broke what happened
      when you tried to set request parameters via $c->req->param('foo', 'bar').
diff --cc lib/Catalyst.pm
Simple merge
@@@ -60,29 -60,58 +60,82 @@@ is
  );
  
  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, '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(
+ #     Catalyst::uri_for( 'TestApp', 'bar/baz' )->as_string,
+ #     '/yada/bar/baz',
+ #     'URI for relative path, called with only class name'
+ # );
+ is(
+     Catalyst::uri_for( 'TestApp', '/', 'arg1', 'arg2' )->as_string,
+     '/arg1/arg2',
+     'URI for root action with args, called with only class name'
+ );
+ ## relative action (or path) doesn't make sense when calling as class method
+ # is( Catalyst::uri_for( 'TestApp', '../quux' )->as_string,
+ #     '/quux', 'URI for relative dot path, called with only class name' );
+ is(
+     Catalyst::uri_for( 'TestApp', '/quux', { param1 => 'value1' } )->as_string,
+     '/quux?param1=value1',
+     'URI for quux action with query params, called with only class name'
+ );
+ is (Catalyst::uri_for( 'TestApp', '/bar/wibble?' )->as_string,
+    '/bar/wibble%3F', 'Question Mark gets encoded, called with only class name'
+ );
+ ## relative action (or path) doesn't make sense when calling as class method
+ # is( Catalyst::uri_for( 'TestApp', qw/bar wibble?/, 'with space' )->as_string,
+ #     '/yada/bar/wibble%3F/with%20space', 'Space gets encoded, called with only class name'
+ # );
+ is(
+     Catalyst::uri_for( 'TestApp', '/bar', 'with+plus', { 'also' => 'with+plus' })->as_string,
+     '/bar/with+plus?also=with%2Bplus',
+     'Plus is not encoded, 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,