[Catalyst-dev] Mangled URI with escapes in Catalyst::Engine::FastCGI (lighttpd)

Vipul Ved Prakash mail at vipul.net
Tue Jan 29 02:28:20 GMT 2008


The following snippet is from Catalyst::Engine::FastCGI -

     while ( $request->Accept >= 0 ) {
         $proc_manager && $proc_manager->pm_pre_dispatch();

         # If we're running under Lighttpd, swap PATH_INFO and  
SCRIPT_NAME
         # http://lists.rawmode.org/pipermail/catalyst/2006-June/008361.html
         # Thanks to Mark Blythe for this fix
         if ( $env{SERVER_SOFTWARE} && $env{SERVER_SOFTWARE} =~ / 
lighttpd/ ) {
             $env{PATH_INFO} ||= delete $env{SCRIPT_NAME};
         }

         $class->handle_request( env => \%env );

         $proc_manager && $proc_manager->pm_post_dispatch();
     }

Line 142, $env{PATH_INFO} is set to $env{SCRIPT_NAME}.   
$env{SCRIPT_NAME} seems to be strangely mangled when the original URI  
contains CGI escapes. For instance:

          http://example.com/url/http%3A%2F%2Ffoo.com
		becomes
          http://example.com/url/http:/foo.com ( single / after http: )

I don't know enough about Catalyst internals to know why this happens  
or why the assignment to $env{SCRIPT_NAME} is used.  I changed line  
142 here to use $env{REQUEST_URI} instead, which fixes this problem -  
though I am not sure if it creates others.

I'd appreciate some insight on this.

cheers,
vipul




More information about the Catalyst-dev mailing list