localhost vs redirect bug
[freeside.git] / rt / lib / RT / Interface / Web.pm
index 814a829..94da307 100644 (file)
@@ -783,7 +783,7 @@ sub Redirect {
     my $redir_to = shift;
     untie $HTML::Mason::Commands::session;
     my $uri        = URI->new($redir_to);
-    my $server_uri = URI->new( RT->Config->Get('WebURL') );
+    my $server_uri = URI->new( _NormalizeHost(RT->Config->Get('WebURL')) );
     
     # Make relative URIs absolute from the server host and scheme
     $uri->scheme($server_uri->scheme) if not defined $uri->scheme;
@@ -1251,8 +1251,9 @@ to handle common problems such as localhost vs 127.0.0.1
 =cut
 
 sub _NormalizeHost {
-
-    my $uri= URI->new(shift);
+    my $s = shift;
+    $s = "http://$s" unless $s =~ /^http/i;
+    my $uri= URI->new($s);
     $uri->host('127.0.0.1') if $uri->host eq 'localhost';
 
     return $uri;