use Bugzilla::Config;
use Bugzilla::Error;
+use Bugzilla::Util;
use base qw(Exporter);
@Bugzilla::Search::Quicksearch::EXPORT = qw(quicksearch);
sub quicksearch {
my ($searchstring) = (@_);
+ my $urlbase = correct_urlbase();
# Remove leading and trailing commas and whitespace.
$searchstring =~ s/(^[\s,]+|[\s,]+$)//g;
if (index($searchstring, ',') < $[) {
# Single bug number; shortcut to show_bug.cgi.
- print $cgi->redirect(-uri => Param('urlbase') .
- "show_bug.cgi?id=$searchstring");
+ print $cgi->redirect(-uri => "${urlbase}show_bug.cgi?id=$searchstring");
exit;
}
else {
WHERE alias = ?},
undef,
$1)) {
- print $cgi->redirect(-uri => Param('urlbase') .
- "show_bug.cgi?id=$1");
+ print $cgi->redirect(-uri => "${urlbase}show_bug.cgi?id=$1");
exit;
}
}
if ($cgi->param('load')) {
# Param 'load' asks us to display the query in the advanced search form.
- print $cgi->redirect(-uri => Param('urlbase') . "query.cgi?" .
- "format=advanced&" .
+ print $cgi->redirect(-uri => "${urlbase}query.cgi?format=advanced&" .
$modified_query_string);
}
detaint_signed
html_quote url_quote value_quote xml_quote
css_class_quote
- i_am_cgi
+ i_am_cgi correct_urlbase
lsearch max min
diff_arrays diff_strings
trim wrap_comment find_wrap_point
return exists $ENV{'SERVER_SOFTWARE'} ? 1 : 0;
}
+sub correct_urlbase {
+ return Param('urlbase') if Param('ssl') eq 'never';
+
+ if (Param('sslbase')) {
+ return Param('sslbase') if Param('ssl') eq 'always';
+ # Authenticated Sessions
+ return Param('sslbase') if Bugzilla->user->id;
+ }
+
+ # Set to "authenticated sessions" but nobody's logged in, or
+ # sslbase isn't set.
+ return Param('urlbase');
+}
+
sub lsearch {
my ($list,$item) = (@_);
my $count = 0;
# Functions that tell you about your environment
my $is_cgi = i_am_cgi();
+ my $urlbase = correct_urlbase();
# Functions for searching
$loc = lsearch(\@arr, $val);
server. For example, it would return false if the caller is running
in a command-line script.
+=item C<correct_urlbase()>
+
+Returns either the C<sslbase> or C<urlbase> parameter, depending on the
+current setting for the C<ssl> parameter.
+
=back
=head2 Searching