Skip to content

Commit

Permalink
Item10669: rewrite 'http(s?)://localhost:123' to {DefaultUrlHost} _IF…
Browse files Browse the repository at this point in the history
…_ {RemovePortNumber} is set _and_ the protocol matches that in {DefaultUrlHost}.

I'm unsure what should happen if the incoming protocol != the default one, so I'm punting.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@14272 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Mar 10, 2012
1 parent 6a49143 commit ee9b6b1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/lib/Foswiki.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1742,8 +1742,12 @@ sub new {
# useful than the default url host. This is because new CGI("")
# assigns this host by default - it's a default setting, used
# when there is nothing better available.
if ( $this->{urlHost} eq 'http://localhost' ) {
$this->{urlHost} = $Foswiki::cfg{DefaultUrlHost};
if ( $this->{urlHost} =~ /(https?):\/\/localhost/i ) {
my $protocol = $1;
#only replace localhost _if_ the protocol matches the one specified in the DefaultUrlHost
if ($Foswiki::cfg{DefaultUrlHost} =~ /^$protocol/i ) {
$this->{urlHost} = $Foswiki::cfg{DefaultUrlHost};
}
}
}
else {
Expand Down

0 comments on commit ee9b6b1

Please sign in to comment.