[Catalyst] trouble with LocationMatch

Hironori Yoshida yoshida at cpan.org
Sun Oct 29 03:41:32 GMT 2006


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 at cpan.org>



More information about the Catalyst mailing list