summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-12-16 20:17:05 +0100
committerGitHub <noreply@github.com>2017-12-16 20:17:05 +0100
commit334bead74bc9c5e819f14946726eaad40986d636 (patch)
treee7ecf8d4eba2e6a046da8a9dc8828f35b75c7428 /Bugzilla/Util.pm
parent49e0df0d4e1b2f25be4ab36660dac5e47768c9a1 (diff)
downloadbugzilla-334bead74bc9c5e819f14946726eaad40986d636.tar.gz
bugzilla-334bead74bc9c5e819f14946726eaad40986d636.tar.xz
Bug 1403777 - Migrate urlbase from params to localconfig
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r--Bugzilla/Util.pm40
1 files changed, 7 insertions, 33 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index df2f78823..c23e738e6 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -259,34 +259,14 @@ sub i_am_webservice {
# (doing so can mess up XML-RPC).
sub do_ssl_redirect_if_required {
return if !i_am_cgi();
- return if !Bugzilla->params->{'ssl_redirect'};
-
- my $sslbase = Bugzilla->params->{'sslbase'};
+ my $uri = URI->new(Bugzilla->localconfig->{'urlbase'});
+ return if $uri->scheme ne 'https';
# If we're already running under SSL, never redirect.
- return if uc($ENV{HTTPS} || '') eq 'ON';
- # Never redirect if there isn't an sslbase.
- return if !$sslbase;
+ return if $ENV{HTTPS} && $ENV{HTTPS} eq 'on';
Bugzilla->cgi->redirect_to_https();
}
-sub correct_urlbase {
- my $ssl = Bugzilla->params->{'ssl_redirect'};
- my $urlbase = Bugzilla->params->{'urlbase'};
- my $sslbase = Bugzilla->params->{'sslbase'};
-
- if (!$sslbase) {
- return $urlbase;
- }
- elsif ($ssl) {
- return $sslbase;
- }
- else {
- # Return what the user currently uses.
- return (uc($ENV{HTTPS} || '') eq 'ON') ? $sslbase : $urlbase;
- }
-}
-
# Returns the real remote address of the client,
sub remote_ip {
my $remote_ip = $ENV{'REMOTE_ADDR'} || '127.0.0.1';
@@ -383,10 +363,9 @@ sub is_ipv6 {
}
sub use_attachbase {
- my $attachbase = Bugzilla->params->{'attachment_base'};
- return ($attachbase ne ''
- && $attachbase ne Bugzilla->params->{'urlbase'}
- && $attachbase ne Bugzilla->params->{'sslbase'}) ? 1 : 0;
+ my $attachbase = Bugzilla->localconfig->{'attachment_base'};
+ my $urlbase = Bugzilla->localconfig->{'urlbase'};
+ return ($attachbase ne '' && $attachbase ne $urlbase);
}
sub diff_arrays {
@@ -932,7 +911,7 @@ Bugzilla::Util - Generic utility functions for bugzilla
# Functions that tell you about your environment
my $is_cgi = i_am_cgi();
my $is_webservice = i_am_webservice();
- my $urlbase = correct_urlbase();
+ my $urlbase = Bugzilla->localconfig->{urlbase};
# Data manipulation
($removed, $added) = diff_arrays(\@old, \@new);
@@ -1066,11 +1045,6 @@ in a command-line script.
Tells you whether or not the current usage mode is WebServices related
such as JSONRPC or XMLRPC.
-=item C<correct_urlbase()>
-
-Returns either the C<sslbase> or C<urlbase> parameter, depending on the
-current setting for the C<ssl_redirect> parameter.
-
=item C<remote_ip()>
Returns the IP address of the remote client. If Bugzilla is behind