Skip Menu |

This queue is for tickets about the Catalyst-View-Component-SubInclude CPAN distribution.

Report information
The Basics
Id: 52564
Status: resolved
Priority: 0/
Queue: Catalyst-View-Component-SubInclude

People
Owner: Nobody in particular
Requestors: NACHBAUR [...] cpan.org
Cc: mike [...] nachbaur.com
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: mike [...] nachbaur.com
Subject: Using ESI subinclude with absolute paths breaks
If trying to do a subinclude with an absolute path, it seems to break, resulting in output that looks like this: <!--esi <esi:include src="/account/0/ARRAY(0xd28f950)" /> --> The above example was taken from a page rendered at the URI "/account/profile", but I was trying to do a subinclude of "/data/view/user?type=account_profile". I've included a patch that does what I think needs to happen; namely it seems the current implementation assumes the subinclude directive will load a relative URL from the current location. If this isn't the case and my patch doesn't address all situations, what course of action should be taken? Thank you.
Subject: SubInclude-ESI.patch
--- /usr/local/share/perl/5.10.0/Catalyst/View/Component/SubInclude/ESI.pm 2009-12-08 10:57:36.000000000 -0500 +++ /home/nachbaur/tmp/new-ESI.pm 2009-12-08 10:57:33.000000000 -0500 @@ -59,12 +59,16 @@ my $args = ref $params[0] eq 'ARRAY' ? shift @params : []; - my $dispatcher = $c->dispatcher; - my ($action) = $dispatcher->_invoke_as_path( $c, $path, $args ); + my $query_path = $path; + unless ($path =~ m#^/#) { + my $dispatcher = $c->dispatcher; + my ($action) = $dispatcher->_invoke_as_path( $c, $path, $args ); + + my $uri = $c->uri_for( $action, $args, @params ); + $query_path = $uri->path_query; + } - my $uri = $c->uri_for( $action, $args, @params ); - - return '<!--esi <esi:include src="' . $uri->path_query . '" /> -->'; + return '<!--esi <esi:include src="' . $query_path . '" /> -->'; } =head1 SEE ALSO
Subject: Re: [rt.cpan.org #52564] Using ESI subinclude with absolute paths breaks
Date: Tue, 8 Dec 2009 14:16:02 -0200
To: bug-Catalyst-View-Component-SubInclude [...] rt.cpan.org
From: Nilson Santos Figueiredo Junior <nilsonsfj [...] cpan.org>
Hi, When using SubIncludes, you should use the private action path, not the external URL path. Please see: http://search.cpan.org/~nilsonsfj/Catalyst-View-Component-SubInclude-0.07/lib/Catalyst/View/Component/SubInclude/ESI.pm Unfortunately, arbitrary external paths wouldn't work neither with the SubInclude nor the Visit plugins as they are inherently for internal paths (they're similar to $c->forward, so basically, the idea is to use anything you could $c->forward to). If you could provide a patch which adds a new function, specific to the ESI plugin, called "external_subinclude", I would be willing to apply it. -Nilson On Tue, Dec 8, 2009 at 1:59 PM, NACHBAUR via RT <bug-Catalyst-View-Component-SubInclude@rt.cpan.org> wrote: Show quoted text
> Tue Dec 08 10:59:22 2009: Request 52564 was acted upon. > Transaction: Ticket created by NACHBAUR >       Queue: Catalyst-View-Component-SubInclude >     Subject: Using ESI subinclude with absolute paths breaks >   Broken in: (no value) >    Severity: (no value) >       Owner: Nobody >  Requestors: NACHBAUR@cpan.org >      Status: new >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=52564 > > > > If trying to do a subinclude with an absolute path, it seems to break, resulting in output that > looks like this: > >    <!--esi <esi:include src="/account/0/ARRAY(0xd28f950)" /> --> > > The above example was taken from a page rendered at the URI "/account/profile", but I was > trying to do a subinclude of "/data/view/user?type=account_profile". > > I've included a patch that does what I think needs to happen; namely it seems the current > implementation assumes the subinclude directive will load a relative URL from the current > location.  If this isn't the case and my patch doesn't address all situations, what course of action > should be taken? > > Thank you. >
Okay, fair enough. I can see that works when you're composing simple URLs, but how do you suggest I use it if I need to supply query-string arguments on the URL? On Tue Dec 08 11:16:20 2009, NILSONSFJ wrote: Show quoted text
> Hi, > > When using SubIncludes, you should use the private action path, not > the external URL path. > Please see: > > http://search.cpan.org/~nilsonsfj/Catalyst-View-Component- > SubInclude-0.07/lib/Catalyst/View/Component/SubInclude/ESI.pm > > Unfortunately, arbitrary external paths wouldn't work neither with the > SubInclude nor the Visit plugins as they are inherently for internal > paths (they're similar to $c->forward, so basically, the idea is to > use anything you could $c->forward to). > > If you could provide a patch which adds a new function, specific to > the ESI plugin, called "external_subinclude", I would be willing to > apply it. > > -Nilson > > On Tue, Dec 8, 2009 at 1:59 PM, NACHBAUR via RT > <bug-Catalyst-View-Component-SubInclude@rt.cpan.org> wrote:
> > Tue Dec 08 10:59:22 2009: Request 52564 was acted upon. > > Transaction: Ticket created by NACHBAUR > >       Queue: Catalyst-View-Component-SubInclude > >     Subject: Using ESI subinclude with absolute paths breaks > >   Broken in: (no value) > >    Severity: (no value) > >       Owner: Nobody > >  Requestors: NACHBAUR@cpan.org > >      Status: new > >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=52564 > > > > > > > If trying to do a subinclude with an absolute path, it seems to
> break, resulting in output that
> > looks like this: > > > >    <!--esi <esi:include src="/account/0/ARRAY(0xd28f950)" /> --> > > > > The above example was taken from a page rendered at the URI
> "/account/profile", but I was
> > trying to do a subinclude of "/data/view/user?type=account_profile". > > > > I've included a patch that does what I think needs to happen; namely
> it seems the current
> > implementation assumes the subinclude directive will load a relative
> URL from the current
> > location.  If this isn't the case and my patch doesn't address all
> situations, what course of action
> > should be taken? > > > > Thank you. > >
Subject: Re: [rt.cpan.org #52564] Using ESI subinclude with absolute paths breaks
Date: Tue, 8 Dec 2009 14:45:38 -0200
To: bug-Catalyst-View-Component-SubInclude [...] rt.cpan.org
From: Nilson Santos Figueiredo Junior <nilsonsfj [...] cpan.org>
Maybe the docs are bad (and docs patches are also welcome) but you should be able to use the "subinclude" functions just like you would use $c->uri_for(): subinclude('/private/action/path', ['chained_param'], { 'query_param' => 'value' }) The chained params arrayref may be omitted if it's not a chained action: subinclude('/private/action/path', { 'query_param' => 'value' }) Or, if it's an action that takes args, but isn't using Chained you may use it like this: subinclude('/private/action/path', 'non_chained_arg', { 'query_param' => 'value' }) Of course, the query params hashref may also be omitted. So you should be able to build any internal URL $c->uri_for would be able to build. I actually noticed this isn't clear in the docs, so a doc patch would also be great, if you're willing to provide it. -Nilson On Tue, Dec 8, 2009 at 2:27 PM, NACHBAUR via RT <bug-Catalyst-View-Component-SubInclude@rt.cpan.org> wrote: Show quoted text
>       Queue: Catalyst-View-Component-SubInclude >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=52564 > > > Okay, fair enough.  I can see that works when you're composing simple URLs, but how do you > suggest I use it if I need to supply query-string arguments on the URL? > > On Tue Dec 08 11:16:20 2009, NILSONSFJ wrote:
>> Hi, >> >> When using SubIncludes, you should use the private action path, not >> the external URL path. >> Please see: >> >>   http://search.cpan.org/~nilsonsfj/Catalyst-View-Component- >> SubInclude-0.07/lib/Catalyst/View/Component/SubInclude/ESI.pm >> >> Unfortunately, arbitrary external paths wouldn't work neither with the >> SubInclude nor the Visit plugins as they are inherently for internal >> paths (they're similar to $c->forward, so basically, the idea is to >> use anything you could $c->forward to). >> >> If you could provide a patch which adds a new function, specific to >> the ESI plugin, called "external_subinclude", I would be willing to >> apply it. >> >> -Nilson >> >> On Tue, Dec 8, 2009 at 1:59 PM, NACHBAUR via RT >> <bug-Catalyst-View-Component-SubInclude@rt.cpan.org> wrote:
>> > Tue Dec 08 10:59:22 2009: Request 52564 was acted upon. >> > Transaction: Ticket created by NACHBAUR >> >       Queue: Catalyst-View-Component-SubInclude >> >     Subject: Using ESI subinclude with absolute paths breaks >> >   Broken in: (no value) >> >    Severity: (no value) >> >       Owner: Nobody >> >  Requestors: NACHBAUR@cpan.org >> >      Status: new >> >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=52564 > >> > >> > >> > If trying to do a subinclude with an absolute path, it seems to
>> break, resulting in output that
>> > looks like this: >> > >> >    <!--esi <esi:include src="/account/0/ARRAY(0xd28f950)" /> --> >> > >> > The above example was taken from a page rendered at the URI
>> "/account/profile", but I was
>> > trying to do a subinclude of "/data/view/user?type=account_profile". >> > >> > I've included a patch that does what I think needs to happen; namely
>> it seems the current
>> > implementation assumes the subinclude directive will load a relative
>> URL from the current
>> > location.  If this isn't the case and my patch doesn't address all
>> situations, what course of action
>> > should be taken? >> > >> > Thank you. >> >
> > > >
Closing this as the original request is invalid, the docs have been somewhat updated since and a doc patch hasn't been forthcoming.