[Catalyst-commits] r6238 - in trunk/Catalyst-Engine-Apache: . lib/Catalyst/Engine

andyg at dev.catalyst.perl.org andyg at dev.catalyst.perl.org
Thu Mar 29 19:11:24 GMT 2007


Author: andyg
Date: 2007-03-29 19:11:23 +0100 (Thu, 29 Mar 2007)
New Revision: 6238

Modified:
   trunk/Catalyst-Engine-Apache/Changes
   trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm
Log:
Apache: use the unparsed URI instead of the pre-parsed URI for building the path

Modified: trunk/Catalyst-Engine-Apache/Changes
===================================================================
--- trunk/Catalyst-Engine-Apache/Changes	2007-03-29 03:32:56 UTC (rev 6237)
+++ trunk/Catalyst-Engine-Apache/Changes	2007-03-29 18:11:23 UTC (rev 6238)
@@ -1,5 +1,9 @@
 This file documents the revision history for Catalyst::Engine::Apache.
 
+1.10
+        - Use the unparsed URI for building the path instead of Apache's
+          pre-parsed URI.
+
 1.09    2007-03-28 23:00:00
         - Fixed compatibility with older Catalyst versions.  5.7008+
           is recommended for best performance.

Modified: trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm
===================================================================
--- trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm	2007-03-29 03:32:56 UTC (rev 6237)
+++ trunk/Catalyst-Engine-Apache/lib/Catalyst/Engine/Apache.pm	2007-03-29 18:11:23 UTC (rev 6238)
@@ -9,8 +9,14 @@
 use URI::http;
 use URI::https;
 
-our $VERSION = '1.09';
+use mod_perl;
+use constant MP2 => ( 
+    exists $ENV{MOD_PERL_API_VERSION} and 
+           $ENV{MOD_PERL_API_VERSION} >= 2
+);
 
+our $VERSION = '1.10';
+
 __PACKAGE__->mk_accessors(qw/apache return/);
 
 sub prepare_request {
@@ -123,12 +129,21 @@
         $host .= ":$port";
     }
     
-    # Escape the path
-    my $path = $self->apache->uri;
-    $path   =~ s{^/+}{};
-    $path   =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
-    $path   =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE
+    # We want the unescaped path.  Under mod_perl2 this is available with the
+    # unparsed_uri method.  Under mod_perl 1 we must parse it out of the request line.
+    my ($path, $qs);
     
+    if ( MP2 ) {
+        ($path, $qs) = split /\?/, $self->apache->unparsed_uri, 2;
+    }
+    else {
+        my (undef, $path_query) = split / /, $self->apache->the_request, 3;
+        ($path, $qs)            = split /\?/, $path_query, 2;
+    }
+    
+    # Strip leading slash
+    $path =~ s{^/+}{};
+    
     # If the path is contained within the base, we need to make the path
     # match base.  This handles the case where the app is running at /deep/path
     # but a request to /deep/path fails where /deep/path/ does not.
@@ -137,7 +152,6 @@
         $path =~ s{^/+}{};
     }
     
-    my $qs    = $self->apache->args;
     my $query = $qs ? '?' . $qs : '';
     my $uri   = $scheme . '://' . $host . '/' . $path . $query;
 




More information about the Catalyst-commits mailing list