FAQ
I have a problem when using <LocationMatch "REGEXP"> to specify the
location of Catalyst.
When I use <LocationMatch>, $c->req->path and $c->req->base includes REGEXP.
e.g. http://localhost:3000/%5E/.*$/

Environment:
Catalyst: 5.008001
Apache: 2.2.2-1 (Cygwin)
ModPerl: 2.0.2

I found the same problem in this ML.
http://lists.rawmode.org/pipermail/catalyst/2005-December/003440.html.
However, the answer is "don't use REGEXP".

So I created a patch following.
------------------------------
% diff -Nau Catalyst/Engine/Apache.pm.orig Catalyst/Engine/Apache.pm
--- Catalyst/Engine/Apache.pm.orig 2006-10-28 12:39:47.079233600 +0900
+++ Catalyst/Engine/Apache.pm 2006-10-28 18:53:32.058046400 +0900
@@ -94,7 +94,8 @@
# Are we running in a non-root Location block?
my $location = $self->apache->location;
if ( $location && $location ne '/' ) {
- $base_path = $location;
+ $self->apache->path_info =~ m/$location/msx;
+ $base_path = $&; # I know this is the match-vars
}

# Are we an Apache::Registry script? Why anyone would ever want to run
------------------------------

When there are two configurations,

httpd.conf-1
<Location "/abc">
SetHandler modperl
PerlResponseHandler MyApp
</Location>

httpd.conf-2
<LocationMatch "^/[^/]+">
SetHandler modperl
PerlResponseHandler MyApp
</LocationMatch>

and request to http://localhost:3000/abc/def/ghi,
then both of $c->req->base are http://localhost:3000/abc/
and both of $c->req->path are def/ghi.
It works well in this case.

However, the patch is just a sample.
I want the opinion about it.

Thank you.


--
Hironori Yoshida <yoshida@cpan.org>

Search Discussions

  • Matt S Trout at Oct 29, 2006 at 4:35 am

    Hironori Yoshida wrote:
    However, the patch is just a sample.
    I want the opinion about it.
    Without it including additions to the tests we've no idea what it does or
    whethr it works so can't really give you an opinion. Any chance of a test or
    three?

    --
    Matt S Trout Offering custom development, consultancy and support
    Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
    Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information

    + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
  • Dave Howorth at Oct 30, 2006 at 10:33 am

    Hironori Yoshida wrote:
    - $base_path = $location;
    + $self->apache->path_info =~ m/$location/msx;
    + $base_path = $&; # I know this is the match-vars
    Programming Perl, Third Edition

    24.2.1. Time Efficiency

    Avoid $& and its two buddies, $` and $'. Any occurrence in your program
    causes all matches to save the searched string for possible future
    reference. (However, once you've blown it, it doesn't hurt to have more
    of them.)

    Cheers, Dave
  • Aristotle Pagaltzis at Oct 30, 2006 at 1:27 pm

    * Dave Howorth [2006-10-30 11:40]:
    Hironori Yoshida wrote:
    - $base_path = $location;
    + $self->apache->path_info =~ m/$location/msx;
    + $base_path = $&; # I know this is the match-vars
    Programming Perl, Third Edition

    24.2.1. Time Efficiency

    Avoid $& and its two buddies, $` and $'. Any occurrence in your
    program causes all matches to save the searched string for
    possible future reference. (However, once you've blown it, it
    doesn't hurt to have more of them.)
    Besides the trivial fact that it?s buggy because it doesn?t
    `quotemeta` the `$location` before using it as a regex.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedOct 29, '06 at 3:41a
activeOct 30, '06 at 1:27p
posts4
users4
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase