Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Chained, slashes, and escaping

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


jspath at pangeamedia

Mar 5, 2007, 12:33 PM

Post #1 of 8 (398 views)
Permalink
Chained, slashes, and escaping

I'm implementing tagging under Catalyst and want to be as unrestrictive
as possible on the tag text. As such, I allow slashes in the tag text.

To view information on a given tag, you hit the following path:

/tag/URI_ESCAPED_TAG

Which uses the following action in the Tag controller:

sub view : PathPart('tag') Chained('/') Args {
my ($self, $c, $tag) = @_;

To test and make sure the escaping is working properly I created the
following tag:

sl/ashes

When I access the following URI:

/tag/sl%2Fashes

$tag gets set to sl instead of sl/ashes.

Chained appears to be using the unescaped path when it looks for the
separator instead of the actual path.

Is this a bug or a feature? How can I work around it?

- Jim

_______________________________________________
List: Catalyst[at]lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


hutchinson.chris at gmail

Mar 5, 2007, 8:46 PM

Post #2 of 8 (372 views)
Permalink
Re: Chained, slashes, and escaping [In reply to]

On 3/6/07, Jim Spath <jspath[at]pangeamedia.com> wrote:
> I'm implementing tagging under Catalyst and want to be as unrestrictive
> as possible on the tag text. As such, I allow slashes in the tag text.
>
> To view information on a given tag, you hit the following path:
>
> /tag/URI_ESCAPED_TAG
>
> Which uses the following action in the Tag controller:
>
> sub view : PathPart('tag') Chained('/') Args {
> my ($self, $c, $tag) = @_;
>
> To test and make sure the escaping is working properly I created the
> following tag:
>
> sl/ashes
>
> When I access the following URI:
>
> /tag/sl%2Fashes
>
> $tag gets set to sl instead of sl/ashes.
>
> Chained appears to be using the unescaped path when it looks for the
> separator instead of the actual path.
>
> Is this a bug or a feature? How can I work around it?
>
> - Jim
>

I cheated and replace '/' with '_' when outputting links when
confronted with a similar issue, then s/_/\//og in the handler. Don't
know if that will work for you?

- Chris

_______________________________________________
List: Catalyst[at]lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


jon at jrock

Mar 5, 2007, 9:10 PM

Post #3 of 8 (372 views)
Permalink
Re: Chained, slashes, and escaping [In reply to]

On Monday 05 March 2007 14:33, Jim Spath wrote:
> When I access the following URI:
>
> /tag/sl%2Fashes
>
> $tag gets set to sl instead of sl/ashes.

Apparently back in the early days of the web, a URL like that caused problems
with poorly written CGI scripts that blindly opened the PATH_INFO variable.
Instead of fixing the scripts, the apache / NCSA HTTPD authors decided to
break the URL spec for the rest of forever.

http://mail-archives.apache.org/mod_mbox/httpd-dev/199612.mbox/%3C9612031142.aa27069[at]paris.ics.uci.edu%3E

11 years later, the web is still broken (for backwards compatibility, of
course).

--
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;

_______________________________________________
List: Catalyst[at]lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


matt.lawrence at ymogen

Mar 6, 2007, 2:00 AM

Post #4 of 8 (369 views)
Permalink
Re: Chained, slashes, and escaping [In reply to]

Jim Spath wrote:
> I'm implementing tagging under Catalyst and want to be as
> unrestrictive as possible on the tag text. As such, I allow slashes
> in the tag text.
>
> To view information on a given tag, you hit the following path:
>
> /tag/URI_ESCAPED_TAG
>
> Which uses the following action in the Tag controller:
>
> sub view : PathPart('tag') Chained('/') Args {
> my ($self, $c, $tag) = @_;
>
How about:

my ($self, $c, @tag_parts) = @_;
my $tag = join('/', @tag_parts);

Matt



_______________________________________________
List: Catalyst[at]lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


pagaltzis at gmx

Mar 6, 2007, 5:09 AM

Post #5 of 8 (374 views)
Permalink
Re: Chained, slashes, and escaping [In reply to]

* Jonathan Rockway <jon[at]jrock.us> [2007-03-06 06:20]:
> Apparently back in the early days of the web, a URL like that
> caused problems with poorly written CGI scripts that blindly
> opened the PATH_INFO variable. Instead of fixing the scripts,
> the apache / NCSA HTTPD authors decided to break the URL spec
> for the rest of forever.
>
> http://mail-archives.apache.org/mod_mbox/httpd-dev/199612.mbox/%3C9612031142.aa27069[at]paris.ics.uci.edu%3E
>
> 11 years later, the web is still broken (for backwards
> compatibility, of course).

http://httpd.apache.org/docs/2.0/mod/core.html#allowencodedslashes

Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>

_______________________________________________
List: Catalyst[at]lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


catalyst at fadetoblack

Mar 6, 2007, 5:13 AM

Post #6 of 8 (369 views)
Permalink
Re: Chained, slashes, and escaping [In reply to]

>> When I access the following URI:
>>
>> /tag/sl%2Fashes
>>
>> $tag gets set to sl instead of sl/ashes.
>
> Apparently back in the early days of the web, a URL like that caused
> problems

I ran into this a couple of weeks ago. As far as I could the development
myapp_server actually deals with everything correctly.

In Apache:

You can now allow encoded slashes in Apache > 2.0.46 with:

AllowEncodedSlashes On


If you're using mod_perl though, when Catalyst fetches the URI from apache
it requests the parsed vesion so for your example would get back
/tag/sl/ashes

You can customise Catalyst::Engine::Apache to use unparsed_uri and split off
the query string - which seems to work OK for my simple case, but I didn't
test any further.

See:

http://lists.scsys.co.uk/pipermail/catalyst-dev/2007-February/000578.html

Carl





_______________________________________________
List: Catalyst[at]lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


jspath at pangeamedia

Mar 6, 2007, 6:13 AM

Post #7 of 8 (376 views)
Permalink
Re: Chained, slashes, and escaping [In reply to]

Unfortunately I'm using lighttpd.

Carl Johnstone wrote:
>>> When I access the following URI:
>>>
>>> /tag/sl%2Fashes
>>>
>>> $tag gets set to sl instead of sl/ashes.
>>
>> Apparently back in the early days of the web, a URL like that caused
>> problems
>
> I ran into this a couple of weeks ago. As far as I could the development
> myapp_server actually deals with everything correctly.
>
> In Apache:
>
> You can now allow encoded slashes in Apache > 2.0.46 with:
>
> AllowEncodedSlashes On
>
>
> If you're using mod_perl though, when Catalyst fetches the URI from
> apache it requests the parsed vesion so for your example would get back
> /tag/sl/ashes
>
> You can customise Catalyst::Engine::Apache to use unparsed_uri and split
> off the query string - which seems to work OK for my simple case, but I
> didn't test any further.
>
> See:
>
> http://lists.scsys.co.uk/pipermail/catalyst-dev/2007-February/000578.html
>
> Carl

_______________________________________________
List: Catalyst[at]lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


jspath at pangeamedia

Mar 6, 2007, 6:14 AM

Post #8 of 8 (368 views)
Permalink
Re: Chained, slashes, and escaping [In reply to]

Hi Matt, I had considered that. I just wanted to check with the list
before I went that route.

Thanks!
- Jim

Matt Lawrence wrote:
> Jim Spath wrote:
>> I'm implementing tagging under Catalyst and want to be as
>> unrestrictive as possible on the tag text. As such, I allow slashes
>> in the tag text.
>>
>> To view information on a given tag, you hit the following path:
>>
>> /tag/URI_ESCAPED_TAG
>>
>> Which uses the following action in the Tag controller:
>>
>> sub view : PathPart('tag') Chained('/') Args {
>> my ($self, $c, $tag) = @_;
>>
> How about:
>
> my ($self, $c, @tag_parts) = @_;
> my $tag = join('/', @tag_parts);
>
> Matt


--
Jim Spath
Lead Developer
Pangea Media
Em: jspath[at]pangeamedia.com
Ph: 617.314.6687
Fx: 617.390.7824
IM: panJimS (AIM)

_______________________________________________
List: Catalyst[at]lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.