[Rt-devel] RT::Interface::Web::Redirect() broken (for 3.6) in split front/back proxying setup

Chris Stromsoe cbs at cts.ucla.edu
Tue Jun 19 13:15:45 EDT 2007


On Mon, 18 Jun 2007, Jesse Vincent wrote:
> On Jun 15, 2007, at 4:20 PM, Chris Stromsoe wrote:
>
>> Can the code block be changed to refer to set variables in 
>> RT_SiteConfig.pm instead of the environment hash?  Or to check for 
>> something that was set intentionally?  Or to check if the redirect 
>> should always be to the canonical name?
>> 
> So yeah, I think that a config file flag for "always canonicalize on 
> redirct" would be a welcome patch for 3.6.5. Is that something you can 
> whip up?

Nothing fancy, but I've added a call in RT_SiteConfig.pm to:

     Set($CanonicalRedirect, 1);

and then modified Redirect() with a one-liner to this:

     sub Redirect {
         my $redir_to = shift;
         untie $HTML::Mason::Commands::session;
         my $uri = URI->new($redir_to);
         my $server_uri = URI->new($RT::WebURL);

         # If the user is coming in via a non-canonical
         # hostname, don't redirect them to the canonical host,
         # it will just upset them (and invalidate their credentials)
         if ((!defined $RT::CanonicalRedirect || $RT::CanonicalRedirect == 0) &&
             $uri->host  eq $server_uri->host &&
             $uri->port eq $server_uri->port) {
                 $uri->host($ENV{'HTTP_HOST'});
                 $uri->port($ENV{'SERVER_PORT'});
             }

         $HTML::Mason::Commands::m->redirect($uri->canonical);
         $HTML::Mason::Commands::m->abort;
     }


That preserves the current behavior by default, only doing a canonical 
redirect if CanonicalRedirect is set to some non-zero value.



-Chris


More information about the Rt-devel mailing list