Commit 9488a890 authored by bbaetz%acm.org's avatar bbaetz%acm.org

Bug 201816 - use CGI.pm for header output

r=joel, a=justdave
parent c000c0a4
...@@ -70,9 +70,13 @@ sub login { ...@@ -70,9 +70,13 @@ sub login {
undef, undef,
$userid, $ipaddr); $userid, $ipaddr);
my $logincookie = $dbh->selectrow_array("SELECT LAST_INSERT_ID()"); my $logincookie = $dbh->selectrow_array("SELECT LAST_INSERT_ID()");
my $cookiepath = Param("cookiepath");
print "Set-Cookie: Bugzilla_login=$userid ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; $cgi->send_cookie(-name => 'Bugzilla_login',
print "Set-Cookie: Bugzilla_logincookie=$logincookie ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; -value => $userid,
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
$cgi->send_cookie(-name => 'Bugzilla_logincookie',
-value => $logincookie,
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
# compat code. The cookie value is used for logouts, and that # compat code. The cookie value is used for logouts, and that
# isn't generic yet. # isn't generic yet.
...@@ -120,7 +124,7 @@ sub login { ...@@ -120,7 +124,7 @@ sub login {
if ($authres == AUTH_NODATA && $type == LOGIN_REQUIRED) { if ($authres == AUTH_NODATA && $type == LOGIN_REQUIRED) {
# Throw up the login page # Throw up the login page
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
my $template = Bugzilla->template; my $template = Bugzilla->template;
$template->process("account/auth/login.html.tmpl", $template->process("account/auth/login.html.tmpl",
...@@ -152,9 +156,12 @@ sub login { ...@@ -152,9 +156,12 @@ sub login {
# The account may be disabled # The account may be disabled
if ($authres == AUTH_DISABLED) { if ($authres == AUTH_DISABLED) {
# Clear the cookie # Clear the cookie
my $cookiepath = Param("cookiepath");
print "Set-Cookie: Bugzilla_login= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT\n"; $cgi->send_cookie(-name => 'Bugzilla_login',
print "Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT\n"; -expires => "Tue, 15-Sep-1998 21:49:00 GMT");
$cgi->send_cookie(-name => 'Bugzilla_logincookie',
-expires => "Tue, 15-Sep-1998 21:49:00 GMT");
# and throw a user error # and throw a user error
&::ThrowUserError("account_disabled", &::ThrowUserError("account_disabled",
{'disabled_reason' => $extra}); {'disabled_reason' => $extra});
......
...@@ -23,11 +23,12 @@ use strict; ...@@ -23,11 +23,12 @@ use strict;
package Bugzilla::CGI; package Bugzilla::CGI;
use CGI qw(-no_xhtml -oldstyle_urls :private_tempfiles); use CGI qw(-no_xhtml -oldstyle_urls :private_tempfiles :unique_headers);
use base qw(CGI); use base qw(CGI);
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Config;
# We need to disable output buffering - see bug 179174 # We need to disable output buffering - see bug 179174
$| = 1; $| = 1;
...@@ -44,6 +45,9 @@ sub new { ...@@ -44,6 +45,9 @@ sub new {
my $self = $class->SUPER::new(@args); my $self = $class->SUPER::new(@args);
# Make sure that we don't send any charset headers
$self->charset('');
# Check for errors # Check for errors
# All of the Bugzilla code wants to do this, so do it here instead of # All of the Bugzilla code wants to do this, so do it here instead of
# in each script # in each script
...@@ -62,20 +66,18 @@ sub new { ...@@ -62,20 +66,18 @@ sub new {
# multipart requests, and so should never happen unless there is a # multipart requests, and so should never happen unless there is a
# browser bug. # browser bug.
# Using CGI.pm to do this means that ThrowCodeError prints the print $self->header(-status => $err);
# content-type again...
#print $self->header(-status => $err); # ThrowCodeError wants to print the header, so it grabs Bugzilla->cgi
print "Status: $err\n"; # which creates a new Bugzilla::CGI object, which fails again, which
# ends up here, and calls ThrowCodeError, and then recurses forever.
my $vars = {}; # So don't use it.
if ($err =~ m/(\d{3})\s(.*)/) { # In fact, we can't use templates at all, because we need a CGI object
$vars->{http_error_code} = $1; # to determine the template lang as well as the current url (from the
$vars->{http_error_string} = $2; # template)
} else { # Since this is an internal error which indicates a severe browser bug,
$vars->{http_error_string} = $err; # just die.
} die "CGI parsing error: $err";
&::ThrowCodeError("cgi_error", $vars);
} }
return $self; return $self;
...@@ -105,6 +107,46 @@ sub canonicalise_query { ...@@ -105,6 +107,46 @@ sub canonicalise_query {
return join("&", @parameters); return join("&", @parameters);
} }
# CGI.pm makes this nph, but apache doesn't like that
sub multipart_init {
my $self = shift;
unshift(@_, '-nph' => undef);
return $self->SUPER::multipart_init(@_);
}
sub cookie {
my $self = shift;
# Add the default path in, but only if we're fetching stuff
# (This test fails for |$cgi->cookie(-name=>'x')| which _is_ meant to
# fetch, but thats an ugly notation for the fetch case which we shouldn't
# be using)
unshift(@_, '-path' => Param('cookiepath')) if scalar(@_)>1;
return $self->SUPER::cookie(@_);
}
# The various parts of Bugzilla which create cookies don't want to have to
# pass them arround to all of the callers. Instead, store them locally here,
# and then output as required from |headers|.
# This is done instead of just printing the result from the script, because
# we need to use |$r->header_out| under mod_perl (which is what CGI.pm
# does, and we need to match, plus if we don't |print| anything, we can turn
# off mod_perl/Apache's header parsing for a small perf gain)
sub send_cookie {
my $self = shift;
my $cookie = $self->cookie(@_);
# XXX - mod_perl
print "Set-Cookie: $cookie\r\n";
return;
}
1; 1;
__END__ __END__
...@@ -149,4 +191,21 @@ I<Bugzilla::CGI> also includes additional functions. ...@@ -149,4 +191,21 @@ I<Bugzilla::CGI> also includes additional functions.
This returns a sorted string of the parameters, suitable for use in a url. This returns a sorted string of the parameters, suitable for use in a url.
Values in C<@exclude> are not included in the result. Values in C<@exclude> are not included in the result.
=item C<cookie>
Identical to the CGI.pm C<cookie> routine, except that the cookie path is
automatically added.
=item C<send_cookie>
This routine is identical to CGI.pm's C<cookie> routine, except that the cookie
is sent to the browser, rather than returned. This should be used by all
Bugzilla code (instead of C<cookie> or the C<-cookie> argument to C<header>),
so that under mod_perl the headers can be sent correctly, using C<print> or
the mod_perl APIs as appropriate.
=back =back
=head1 SEE ALSO
L<CGI|CGI>, L<CGI::Cookie|CGI::Cookie>
...@@ -47,7 +47,8 @@ use base qw(Exporter); ...@@ -47,7 +47,8 @@ use base qw(Exporter);
LOGIN_NORMAL LOGIN_NORMAL
LOGIN_REQUIRED LOGIN_REQUIRED
); );
@Bugzilla::Constants::EXPORT_OK = qw(contenttypes);
# CONSTANTS # CONSTANTS
# #
...@@ -94,4 +95,14 @@ use constant LOGIN_OPTIONAL => 0; ...@@ -94,4 +95,14 @@ use constant LOGIN_OPTIONAL => 0;
use constant LOGIN_NORMAL => 1; use constant LOGIN_NORMAL => 1;
use constant LOGIN_REQUIRED => 2; use constant LOGIN_REQUIRED => 2;
use constant contenttypes =>
{
"html" => "text/html" ,
"rdf" => "application/xml" ,
"xml" => "text/xml" ,
"js" => "application/x-javascript" ,
"csv" => "text/plain" ,
"png" => "image/png" ,
};
1; 1;
...@@ -39,8 +39,7 @@ sub ThrowUserError { ...@@ -39,8 +39,7 @@ sub ThrowUserError {
Bugzilla->dbh->do("UNLOCK TABLES") if $unlock_tables; Bugzilla->dbh->do("UNLOCK TABLES") if $unlock_tables;
# XXX - mod_perl print Bugzilla->cgi->header();
print "Content-type: text/html\n\n" if !$::vars->{'header_done'};
my $template = Bugzilla->template; my $template = Bugzilla->template;
$template->process("global/user-error.html.tmpl", $vars) $template->process("global/user-error.html.tmpl", $vars)
......
...@@ -587,7 +587,7 @@ sub notify { ...@@ -587,7 +587,7 @@ sub notify {
my $rv = my $rv =
$::template->process($template_file, $::vars, \$message); $::template->process($template_file, $::vars, \$message);
if (!$rv) { if (!$rv) {
print "Content-Type: text/html\n\n" unless $::vars->{'header_done'}; Bugzilla->cgi->header();
&::ThrowTemplateError($::template->error()); &::ThrowTemplateError($::template->error());
} }
......
...@@ -366,7 +366,7 @@ sub match_field { ...@@ -366,7 +366,7 @@ sub match_field {
$vars->{'matches'} = $matches; # matches that were made $vars->{'matches'} = $matches; # matches that were made
$vars->{'matchsuccess'} = $matchsuccess; # continue or fail $vars->{'matchsuccess'} = $matchsuccess; # continue or fail
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
$::template->process("global/confirm-user-match.html.tmpl", $vars) $::template->process("global/confirm-user-match.html.tmpl", $vars)
|| &::ThrowTemplateError($::template->error()); || &::ThrowTemplateError($::template->error());
......
...@@ -59,7 +59,7 @@ if (Param("shutdownhtml") && $0 !~ m:[\\/](do)?editparams.cgi$:) { ...@@ -59,7 +59,7 @@ if (Param("shutdownhtml") && $0 !~ m:[\\/](do)?editparams.cgi$:) {
$::vars->{'message'} = "shutdown"; $::vars->{'message'} = "shutdown";
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return an HTML message about the downtime. # Generate and return an HTML message about the downtime.
$::template->process("global/message.html.tmpl", $::vars) $::template->process("global/message.html.tmpl", $::vars)
...@@ -320,7 +320,7 @@ sub ThrowCodeError { ...@@ -320,7 +320,7 @@ sub ThrowCodeError {
$vars->{'variables'} = $extra_vars; $vars->{'variables'} = $extra_vars;
} }
print "Content-type: text/html\n\n" if !$vars->{'header_done'}; print Bugzilla->cgi->header();
$template->process("global/code-error.html.tmpl", $vars) $template->process("global/code-error.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -33,7 +33,6 @@ use strict; ...@@ -33,7 +33,6 @@ use strict;
use lib qw(.); use lib qw(.);
use vars qw( use vars qw(
$cgi
$template $template
$vars $vars
); );
...@@ -63,6 +62,8 @@ quietly_check_login(); ...@@ -63,6 +62,8 @@ quietly_check_login();
# to just above validateID(). # to just above validateID().
my $bugid; my $bugid;
my $cgi = Bugzilla->cgi;
################################################################################ ################################################################################
# Main Body Execution # Main Body Execution
################################################################################ ################################################################################
...@@ -399,11 +400,12 @@ sub view ...@@ -399,11 +400,12 @@ sub view
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
$filename =~ s/^.*[\/\\]//; $filename =~ s/^.*[\/\\]//;
my $filesize = length($thedata); my $filesize = length($thedata);
print qq{Content-Type: $contenttype; name="$filename"\n};
print qq{Content-Disposition: inline; filename=$filename\n};
print qq{Content-Length: $filesize\n};
print qq{\n$thedata};
print Bugzilla->cgi->header(-type=>"$contenttype; name=\"$filename\"",
-content_disposition=> "inline; filename=$filename\n",
-content_length => $filesize);
print $thedata;
} }
...@@ -450,8 +452,7 @@ sub viewall ...@@ -450,8 +452,7 @@ sub viewall
$vars->{'bugsummary'} = $bugsummary; $vars->{'bugsummary'} = $bugsummary;
$vars->{'GetBugLink'} = \&GetBugLink; $vars->{'GetBugLink'} = \&GetBugLink;
# Return the appropriate HTTP response headers. print Bugzilla->cgi->header();
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/show-multiple.html.tmpl", $vars) $template->process("attachment/show-multiple.html.tmpl", $vars)
...@@ -495,8 +496,7 @@ sub enter ...@@ -495,8 +496,7 @@ sub enter
$vars->{'bugsummary'} = $bugsummary; $vars->{'bugsummary'} = $bugsummary;
$vars->{'GetBugLink'} = \&GetBugLink; $vars->{'GetBugLink'} = \&GetBugLink;
# Return the appropriate HTTP response headers. print Bugzilla->cgi->header();
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/create.html.tmpl", $vars) $template->process("attachment/create.html.tmpl", $vars)
...@@ -604,8 +604,7 @@ sub insert ...@@ -604,8 +604,7 @@ sub insert
$vars->{'contenttypemethod'} = $::FORM{'contenttypemethod'}; $vars->{'contenttypemethod'} = $::FORM{'contenttypemethod'};
$vars->{'contenttype'} = $::FORM{'contenttype'}; $vars->{'contenttype'} = $::FORM{'contenttype'};
# Return the appropriate HTTP response headers. print Bugzilla->cgi->header();
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/created.html.tmpl", $vars) $template->process("attachment/created.html.tmpl", $vars)
...@@ -667,8 +666,7 @@ sub edit ...@@ -667,8 +666,7 @@ sub edit
$vars->{'attachments'} = \@bugattachments; $vars->{'attachments'} = \@bugattachments;
$vars->{'GetBugLink'} = \&GetBugLink; $vars->{'GetBugLink'} = \&GetBugLink;
# Return the appropriate HTTP response headers. print Bugzilla->cgi->header();
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/edit.html.tmpl", $vars) $template->process("attachment/edit.html.tmpl", $vars)
...@@ -815,8 +813,7 @@ sub update ...@@ -815,8 +813,7 @@ sub update
$vars->{'attachid'} = $::FORM{'id'}; $vars->{'attachid'} = $::FORM{'id'};
$vars->{'bugid'} = $bugid; $vars->{'bugid'} = $bugid;
# Return the appropriate HTTP response headers. print Bugzilla->cgi->header();
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/updated.html.tmpl", $vars) $template->process("attachment/updated.html.tmpl", $vars)
......
...@@ -33,7 +33,7 @@ use strict; ...@@ -33,7 +33,7 @@ use strict;
use lib qw(.); use lib qw(.);
use vars qw($cgi $template $vars); use vars qw($template $vars);
use Bugzilla; use Bugzilla;
use Bugzilla::Search; use Bugzilla::Search;
...@@ -56,10 +56,12 @@ use vars qw($db_name ...@@ -56,10 +56,12 @@ use vars qw($db_name
$userid $userid
@versions); @versions);
my $cgi = Bugzilla->cgi;
if (length($::buffer) == 0) { if (length($::buffer) == 0) {
print "Refresh: 10; URL=query.cgi\n"; print $cgi->header(-refresh=> '10; URL=query.cgi');
ThrowUserError("buglist_parameters_required"); ThrowUserError("buglist_parameters_required");
} }
ConnectToDatabase(); ConnectToDatabase();
...@@ -131,8 +133,7 @@ if ($::FORM{'regetlastlist'}) { ...@@ -131,8 +133,7 @@ if ($::FORM{'regetlastlist'}) {
if ($::buffer =~ /&cmd-/) { if ($::buffer =~ /&cmd-/) {
my $url = "query.cgi?$::buffer#chart"; my $url = "query.cgi?$::buffer#chart";
print "Refresh: 0; URL=$url\n"; print $cgi->redirect(-location => $url);
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$vars->{'message'} = "buglist_adding_field"; $vars->{'message'} = "buglist_adding_field";
$vars->{'url'} = $url; $vars->{'url'} = $url;
...@@ -257,8 +258,7 @@ if ($::FORM{'cmdtype'} eq "dorem") { ...@@ -257,8 +258,7 @@ if ($::FORM{'cmdtype'} eq "dorem") {
} }
elsif ($::FORM{'remaction'} eq "load") { elsif ($::FORM{'remaction'} eq "load") {
my $url = "query.cgi?" . LookupNamedQuery($::FORM{"namedcmd"}); my $url = "query.cgi?" . LookupNamedQuery($::FORM{"namedcmd"});
print "Refresh: 0; URL=$url\n"; print $cgi->redirect(-location=>$url);
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$vars->{'message'} = "buglist_load_named_query"; $vars->{'message'} = "buglist_load_named_query";
$vars->{'namedcmd'} = $::FORM{'namedcmd'}; $vars->{'namedcmd'} = $::FORM{'namedcmd'};
...@@ -282,7 +282,7 @@ if ($::FORM{'cmdtype'} eq "dorem") { ...@@ -282,7 +282,7 @@ if ($::FORM{'cmdtype'} eq "dorem") {
$count++; $count++;
} }
print "Content-Type: text/html\n\n"; print $cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$vars->{'message'} = "buglist_query_gone"; $vars->{'message'} = "buglist_query_gone";
$vars->{'namedcmd'} = $::FORM{'namedcmd'}; $vars->{'namedcmd'} = $::FORM{'namedcmd'};
...@@ -535,8 +535,8 @@ if ($order) { ...@@ -535,8 +535,8 @@ if ($order) {
if (!grep($fragment =~ /^\Q$_\E(\s+(asc|desc))?$/, @columnnames)) { if (!grep($fragment =~ /^\Q$_\E(\s+(asc|desc))?$/, @columnnames)) {
$vars->{'fragment'} = $fragment; $vars->{'fragment'} = $fragment;
if ($order_from_cookie) { if ($order_from_cookie) {
my $cookiepath = Param("cookiepath"); $cgi->send_cookie(-name => 'LASTORDER',
print "Set-Cookie: LASTORDER= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT\n"; -expires => 'Tue, 15-Sep-1998 21:49:00 GMT');
ThrowCodeError("invalid_column_name_cookie"); ThrowCodeError("invalid_column_name_cookie");
} }
else { else {
...@@ -618,15 +618,15 @@ $query .= " ORDER BY $db_order " if ($order); ...@@ -618,15 +618,15 @@ $query .= " ORDER BY $db_order " if ($order);
# Time to use server push to display an interim message to the user until # Time to use server push to display an interim message to the user until
# the query completes and we can display the bug list. # the query completes and we can display the bug list.
if ($serverpush) { if ($serverpush) {
# Generate HTTP headers. print $cgi->multipart_init(-content_disposition => "inline; filename=$filename");
print "Content-Disposition: inline; filename=$filename\n";
print "Content-Type: multipart/x-mixed-replace;boundary=thisrandomstring\n\n"; print $cgi->multipart_start();
print "--thisrandomstring\n";
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("list/server-push.html.tmpl", $vars) $template->process("list/server-push.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
print $cgi->multipart_end();
} }
# Connect to the shadow database if this installation is using one to improve # Connect to the shadow database if this installation is using one to improve
...@@ -800,39 +800,47 @@ if ($dotweak) { ...@@ -800,39 +800,47 @@ if ($dotweak) {
# HTTP Header Generation # HTTP Header Generation
################################################################################ ################################################################################
# If we are doing server push, output a separator string.
print "\n--thisrandomstring\n" if $serverpush;
# Generate HTTP headers # Generate HTTP headers
# Suggest a name for the bug list if the user wants to save it as a file. my $contenttype;
# If we are doing server push, then we did this already in the HTTP headers
# that started the server push, so we don't have to do it again here.
print "Content-Disposition: inline; filename=$filename\n" unless $serverpush;
if ($format->{'extension'} eq "html") { if ($format->{'extension'} eq "html") {
my $cookiepath = Param("cookiepath"); my $cookiepath = Param("cookiepath");
print "Content-Type: text/html\n";
if ($order) { if ($order) {
my $qorder = url_quote($order); my $qorder = url_quote($order);
print "Set-Cookie: LASTORDER=$qorder ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; $cgi->send_cookie(-name => 'LASTORDER',
-value => $qorder,
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
} }
my $bugids = join(":", @bugidlist); my $bugids = join(":", @bugidlist);
# See also Bug 111999 # See also Bug 111999
if (length($bugids) < 4000) { if (length($bugids) < 4000) {
print "Set-Cookie: BUGLIST=$bugids ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; $cgi->send_cookie(-name => 'BUGLIST',
-value => $bugids,
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
} }
else { else {
print "Set-Cookie: BUGLIST= ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; $cgi->send_cookie(-name => 'BUGLIST',
-expires => 'Tue, 15-Sep-1998 21:49:00 GMT');
$vars->{'toolong'} = 1; $vars->{'toolong'} = 1;
} }
$contenttype = "text/html";
} }
else { else {
print "Content-Type: $format->{'ctype'}\n"; $contenttype = $format->{'ctype'};
} }
print "\n"; # end HTTP headers if ($serverpush) {
print $cgi->multipart_start(-type=>$contenttype);
} else {
# Suggest a name for the bug list if the user wants to save it as a file.
# If we are doing server push, then we did this already in the HTTP headers
# that started the server push, so we don't have to do it again here.
print $cgi->header(-type => $contenttype,
-content_disposition => "inline; filename=$filename");
}
################################################################################ ################################################################################
...@@ -848,4 +856,4 @@ $template->process($format->{'template'}, $vars) ...@@ -848,4 +856,4 @@ $template->process($format->{'template'}, $vars)
# Script Conclusion # Script Conclusion
################################################################################ ################################################################################
print "\n--thisrandomstring--\n" if $serverpush; print $cgi->multipart_final() if $serverpush;
...@@ -211,7 +211,7 @@ my $modules = [ ...@@ -211,7 +211,7 @@ my $modules = [
}, },
{ {
name => 'CGI', name => 'CGI',
version => '2.88' version => '2.93'
}, },
{ {
name => 'Data::Dumper', name => 'Data::Dumper',
...@@ -587,24 +587,6 @@ LocalVar('platforms', ' ...@@ -587,24 +587,6 @@ LocalVar('platforms', '
); );
'); ');
LocalVar('contenttypes', '
#
# The types of content that template files can generate, indexed by file extension.
#
$contenttypes = {
"html" => "text/html" ,
"rdf" => "application/xml" ,
"xml" => "text/xml" ,
"js" => "application/x-javascript" ,
"csv" => "text/plain" ,
"png" => "image/png" ,
};
');
if ($newstuff ne "") { if ($newstuff ne "") {
print "\nThis version of Bugzilla contains some variables that you may want\n", print "\nThis version of Bugzilla contains some variables that you may want\n",
"to change and adapt to your local settings. Please edit the file\n", "to change and adapt to your local settings. Please edit the file\n",
......
...@@ -32,6 +32,8 @@ use vars qw( ...@@ -32,6 +32,8 @@ use vars qw(
$vars $vars
); );
use Bugzilla;
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
...@@ -39,6 +41,8 @@ quietly_check_login(); ...@@ -39,6 +41,8 @@ quietly_check_login();
GetVersionTable(); GetVersionTable();
my $cgi = Bugzilla->cgi;
# The master list not only says what fields are possible, but what order # The master list not only says what fields are possible, but what order
# they get displayed in. # they get displayed in.
my @masterlist = ("opendate", "changeddate", "bug_severity", "priority", my @masterlist = ("opendate", "changeddate", "bug_severity", "priority",
...@@ -87,12 +91,15 @@ if (defined $::FORM{'rememberedquery'}) { ...@@ -87,12 +91,15 @@ if (defined $::FORM{'rememberedquery'}) {
} }
my $list = join(" ", @collist); my $list = join(" ", @collist);
my $urlbase = Param("urlbase"); my $urlbase = Param("urlbase");
my $cookiepath = Param("cookiepath");
$cgi->send_cookie(-name => 'COLUMNLIST',
print "Set-Cookie: COLUMNLIST=$list ; path=$cookiepath ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; -value => $list,
print "Set-Cookie: SPLITHEADER=$::FORM{'splitheader'} ; path=$cookiepath ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
print "Refresh: 0; URL=buglist.cgi?$::FORM{'rememberedquery'}\n"; $cgi->send_cookie(-name => 'SPLITHEADER',
print "Content-type: text/html\n\n"; -value => $::FORM{'splitheader'},
-expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
print $cgi->redirect("buglist.cgi?$::FORM{'rememberedquery'}");
$vars->{'message'} = "change_columns"; $vars->{'message'} = "change_columns";
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -111,6 +118,6 @@ $vars->{'splitheader'} = $::COOKIE{'SPLITHEADER'} ? 1 : 0; ...@@ -111,6 +118,6 @@ $vars->{'splitheader'} = $::COOKIE{'SPLITHEADER'} ? 1 : 0;
$vars->{'buffer'} = $::buffer; $vars->{'buffer'} = $::buffer;
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("list/change-columns.html.tmpl", $vars) $template->process("list/change-columns.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -47,13 +47,16 @@ unless (Bugzilla::Auth->can_edit) { ...@@ -47,13 +47,16 @@ unless (Bugzilla::Auth->can_edit) {
ThrowUserError("auth_cant_create_account"); ThrowUserError("auth_cant_create_account");
} }
my $cgi = Bugzilla->cgi;
# Clear out the login cookies. Make people log in again if they create an # Clear out the login cookies. Make people log in again if they create an
# account; otherwise, they'll probably get confused. # account; otherwise, they'll probably get confused.
my $cookiepath = Param("cookiepath"); $cgi->send_cookie(-name => 'Bugzilla_login',
print "Set-Cookie: Bugzilla_login= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT -expires => 'Tue, 15-Sep-1998 21:49:00 GMT');
Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT\n"; $cgi->send_cookie(-name => 'Bugzilla_logincookie',
-expires => 'Tue, 15-Sep-1998 21:49:00 GMT');
print "Content-Type: text/html\n\n"; print $cgi->header();
my $login = $::FORM{'login'}; my $login = $::FORM{'login'};
......
...@@ -31,6 +31,8 @@ use strict; ...@@ -31,6 +31,8 @@ use strict;
use lib qw(.); use lib qw(.);
use Bugzilla;
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
...@@ -38,6 +40,8 @@ quietly_check_login(); ...@@ -38,6 +40,8 @@ quietly_check_login();
GetVersionTable(); GetVersionTable();
my $cgi = Bugzilla->cgi;
if (!defined $::FORM{'product'}) { if (!defined $::FORM{'product'}) {
# Reference to a subset of %::proddesc, which the user is allowed to see # Reference to a subset of %::proddesc, which the user is allowed to see
my %products; my %products;
...@@ -63,7 +67,7 @@ if (!defined $::FORM{'product'}) { ...@@ -63,7 +67,7 @@ if (!defined $::FORM{'product'}) {
$::vars->{'proddesc'} = \%products; $::vars->{'proddesc'} = \%products;
$::vars->{'target'} = "describecomponents.cgi"; $::vars->{'target'} = "describecomponents.cgi";
print "Content-type: text/html\n\n"; print $cgi->header();
$::template->process("global/choose-product.html.tmpl", $::vars) $::template->process("global/choose-product.html.tmpl", $::vars)
|| ThrowTemplateError($::template->error()); || ThrowTemplateError($::template->error());
exit; exit;
...@@ -118,7 +122,7 @@ while (MoreSQLData()) { ...@@ -118,7 +122,7 @@ while (MoreSQLData()) {
$::vars->{'product'} = $product; $::vars->{'product'} = $product;
$::vars->{'components'} = \@components; $::vars->{'components'} = \@components;
print "Content-type: text/html\n\n"; print $cgi->header();
$::template->process("reports/components.html.tmpl", $::vars) $::template->process("reports/components.html.tmpl", $::vars)
|| ThrowTemplateError($::template->error()); || ThrowTemplateError($::template->error());
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
use strict; use strict;
use lib "."; use lib ".";
use Bugzilla;
require "CGI.pl"; require "CGI.pl";
# Use the global template variables. # Use the global template variables.
...@@ -33,6 +35,8 @@ ConnectToDatabase(); ...@@ -33,6 +35,8 @@ ConnectToDatabase();
quietly_check_login(); quietly_check_login();
my $cgi = Bugzilla->cgi;
SendSQL("SELECT keyworddefs.name, keyworddefs.description, SendSQL("SELECT keyworddefs.name, keyworddefs.description,
COUNT(keywords.bug_id) COUNT(keywords.bug_id)
FROM keyworddefs LEFT JOIN keywords ON keyworddefs.id=keywords.keywordid FROM keyworddefs LEFT JOIN keywords ON keyworddefs.id=keywords.keywordid
...@@ -52,6 +56,6 @@ while (MoreSQLData()) { ...@@ -52,6 +56,6 @@ while (MoreSQLData()) {
$vars->{'keywords'} = \@keywords; $vars->{'keywords'} = \@keywords;
$vars->{'caneditkeywords'} = UserInGroup("editkeywords"); $vars->{'caneditkeywords'} = UserInGroup("editkeywords");
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("reports/keywords.html.tmpl", $vars) $template->process("reports/keywords.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -25,6 +25,7 @@ use strict; ...@@ -25,6 +25,7 @@ use strict;
use lib qw(.); use lib qw(.);
use Bugzilla;
use Bugzilla::Config qw(:DEFAULT :admin); use Bugzilla::Config qw(:DEFAULT :admin);
require "CGI.pl"; require "CGI.pl";
...@@ -34,7 +35,9 @@ use vars %::MFORM; ...@@ -34,7 +35,9 @@ use vars %::MFORM;
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; my $cgi = Bugzilla->cgi;
print $cgi->header();
if (!UserInGroup("tweakparams")) { if (!UserInGroup("tweakparams")) {
print "<H1>Sorry, you aren't a member of the 'tweakparams' group.</H1>\n"; print "<H1>Sorry, you aren't a member of the 'tweakparams' group.</H1>\n";
......
...@@ -36,15 +36,18 @@ use vars qw($buffer); ...@@ -36,15 +36,18 @@ use vars qw($buffer);
use Bugzilla; use Bugzilla;
use Bugzilla::Search; use Bugzilla::Search;
use Bugzilla::CGI;
my $cgi = Bugzilla->cgi;
# Go directly to the XUL version of the duplicates report (duplicates.xul) # Go directly to the XUL version of the duplicates report (duplicates.xul)
# if the user specified ctype=xul. Adds params if they exist, and directs # if the user specified ctype=xul. Adds params if they exist, and directs
# the user to a signed copy of the script in duplicates.jar if it exists. # the user to a signed copy of the script in duplicates.jar if it exists.
if ($::FORM{'ctype'} && $::FORM{'ctype'} eq "xul") { if ($::FORM{'ctype'} && $::FORM{'ctype'} eq "xul") {
my $params = CanonicaliseParams($::buffer, ["format", "ctype"]); my $params = CanonicaliseParams($::buffer, ["format", "ctype"]);
print "Location: " . (-e "duplicates.jar" ? "duplicates.jar!/" : "") . my $url = (-e "duplicates.jar" ? "duplicates.jar!/" : "") .
"duplicates.xul" . ($params ? "?$params" : "") . "\n\n"; "duplicates.xul" . ($params ? "?$params" : "") . "\n\n";
print $cgi->redirect($url);
exit; exit;
} }
...@@ -261,8 +264,8 @@ $vars->{'products'} = \@::legal_product; ...@@ -261,8 +264,8 @@ $vars->{'products'} = \@::legal_product;
my $format = my $format =
GetFormat("reports/duplicates", $::FORM{'format'}, $::FORM{'ctype'}); GetFormat("reports/duplicates", $::FORM{'format'}, $::FORM{'ctype'});
print "Content-Type: $format->{'ctype'}\n\n"; print $cgi->header($format->{'ctype'});
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process($format->{'template'}, $vars) $template->process($format->{'template'}, $vars)
......
...@@ -191,7 +191,7 @@ sub PutTrailer (@) ...@@ -191,7 +191,7 @@ sub PutTrailer (@)
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
unless (UserInGroup("editcomponents")) { unless (UserInGroup("editcomponents")) {
PutHeader("Not allowed"); PutHeader("Not allowed");
......
...@@ -35,6 +35,7 @@ require "CGI.pl"; ...@@ -35,6 +35,7 @@ require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
# Use Bugzilla's flag modules for handling flag types. # Use Bugzilla's flag modules for handling flag types.
use Bugzilla;
use Bugzilla::Flag; use Bugzilla::Flag;
use Bugzilla::FlagType; use Bugzilla::FlagType;
...@@ -94,7 +95,7 @@ sub list { ...@@ -94,7 +95,7 @@ sub list {
Bugzilla::FlagType::match({ 'target_type' => 'attachment' }, 1); Bugzilla::FlagType::match({ 'target_type' => 'attachment' }, 1);
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/list.html.tmpl", $vars) $template->process("admin/flag-type/list.html.tmpl", $vars)
...@@ -138,7 +139,7 @@ sub edit { ...@@ -138,7 +139,7 @@ sub edit {
} }
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/edit.html.tmpl", $vars) $template->process("admin/flag-type/edit.html.tmpl", $vars)
...@@ -189,7 +190,7 @@ sub processCategoryChange { ...@@ -189,7 +190,7 @@ sub processCategoryChange {
$vars->{'type'} = $type; $vars->{'type'} = $type;
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/edit.html.tmpl", $vars) $template->process("admin/flag-type/edit.html.tmpl", $vars)
...@@ -246,7 +247,7 @@ sub insert { ...@@ -246,7 +247,7 @@ sub insert {
$vars->{'message'} = "flag_type_created"; $vars->{'message'} = "flag_type_created";
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
...@@ -328,7 +329,7 @@ sub update { ...@@ -328,7 +329,7 @@ sub update {
$vars->{'message'} = "flag_type_changes_saved"; $vars->{'message'} = "flag_type_changes_saved";
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
...@@ -348,7 +349,7 @@ sub confirmDelete ...@@ -348,7 +349,7 @@ sub confirmDelete
$vars->{'flag_count'} = scalar($count); $vars->{'flag_count'} = scalar($count);
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/confirm-delete.html.tmpl", $vars) $template->process("admin/flag-type/confirm-delete.html.tmpl", $vars)
...@@ -380,7 +381,7 @@ sub delete { ...@@ -380,7 +381,7 @@ sub delete {
$vars->{'message'} = "flag_type_deleted"; $vars->{'message'} = "flag_type_deleted";
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
...@@ -400,7 +401,7 @@ sub deactivate { ...@@ -400,7 +401,7 @@ sub deactivate {
$vars->{'flag_type'} = Bugzilla::FlagType::get($::FORM{'id'}); $vars->{'flag_type'} = Bugzilla::FlagType::get($::FORM{'id'});
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
......
...@@ -33,7 +33,7 @@ require "CGI.pl"; ...@@ -33,7 +33,7 @@ require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
if (!UserInGroup("creategroups")) { if (!UserInGroup("creategroups")) {
PutHeader("Not Authorized","Edit Groups","","Not Authorized for this function!"); PutHeader("Not Authorized","Edit Groups","","Not Authorized for this function!");
......
...@@ -110,7 +110,7 @@ sub Validate ($$) { ...@@ -110,7 +110,7 @@ sub Validate ($$) {
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
unless (UserInGroup("editkeywords")) { unless (UserInGroup("editkeywords")) {
PutHeader("Not allowed"); PutHeader("Not allowed");
......
...@@ -148,7 +148,7 @@ sub PutTrailer (@) ...@@ -148,7 +148,7 @@ sub PutTrailer (@)
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
unless (UserInGroup("editcomponents")) { unless (UserInGroup("editcomponents")) {
PutHeader("Not allowed"); PutHeader("Not allowed");
......
...@@ -32,7 +32,7 @@ require "CGI.pl"; ...@@ -32,7 +32,7 @@ require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
if (!UserInGroup("tweakparams")) { if (!UserInGroup("tweakparams")) {
print "<H1>Sorry, you aren't a member of the 'tweakparams' group.</H1>\n"; print "<H1>Sorry, you aren't a member of the 'tweakparams' group.</H1>\n";
......
...@@ -178,7 +178,7 @@ sub PutTrailer (@) ...@@ -178,7 +178,7 @@ sub PutTrailer (@)
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
unless (UserInGroup("editcomponents")) { unless (UserInGroup("editcomponents")) {
PutHeader("Not allowed"); PutHeader("Not allowed");
......
...@@ -236,7 +236,7 @@ sub PutTrailer (@) ...@@ -236,7 +236,7 @@ sub PutTrailer (@)
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
$editall = UserInGroup("editusers"); $editall = UserInGroup("editusers");
......
...@@ -157,7 +157,7 @@ sub PutTrailer (@) ...@@ -157,7 +157,7 @@ sub PutTrailer (@)
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
unless (UserInGroup("editcomponents")) { unless (UserInGroup("editcomponents")) {
PutHeader("Not allowed"); PutHeader("Not allowed");
......
...@@ -36,6 +36,7 @@ use strict; ...@@ -36,6 +36,7 @@ use strict;
use lib qw(.); use lib qw(.);
use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
require "CGI.pl"; require "CGI.pl";
...@@ -65,6 +66,8 @@ ConnectToDatabase(); ...@@ -65,6 +66,8 @@ ConnectToDatabase();
# user is right from the start. # user is right from the start.
confirm_login() if AnyEntryGroups(); confirm_login() if AnyEntryGroups();
my $cgi = Bugzilla->cgi;
if (!defined $::FORM{'product'}) { if (!defined $::FORM{'product'}) {
GetVersionTable(); GetVersionTable();
quietly_check_login(); quietly_check_login();
...@@ -88,7 +91,7 @@ if (!defined $::FORM{'product'}) { ...@@ -88,7 +91,7 @@ if (!defined $::FORM{'product'}) {
$vars->{'target'} = "enter_bug.cgi"; $vars->{'target'} = "enter_bug.cgi";
$vars->{'format'} = $::FORM{'format'}; $vars->{'format'} = $::FORM{'format'};
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("global/choose-product.html.tmpl", $vars) $template->process("global/choose-product.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
...@@ -364,7 +367,7 @@ $vars->{'use_keywords'} = 1 if (@::legal_keywords); ...@@ -364,7 +367,7 @@ $vars->{'use_keywords'} = 1 if (@::legal_keywords);
my $format = my $format =
GetFormat("bug/create/create", $::FORM{'format'}, $::FORM{'ctype'}); GetFormat("bug/create/create", $::FORM{'format'}, $::FORM{'ctype'});
print "Content-type: $format->{'ctype'}\n\n"; print $cgi->header($format->{'ctype'});
$template->process($format->{'template'}, $vars) $template->process($format->{'template'}, $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -40,7 +40,6 @@ use Bugzilla::Config qw(:DEFAULT ChmodDataFile); ...@@ -40,7 +40,6 @@ use Bugzilla::Config qw(:DEFAULT ChmodDataFile);
sub globals_pl_sillyness { sub globals_pl_sillyness {
my $zz; my $zz;
$zz = @main::SqlStateStack; $zz = @main::SqlStateStack;
$zz = $main::contenttypes;
$zz = @main::default_column_list; $zz = @main::default_column_list;
$zz = $main::defaultqueryname; $zz = $main::defaultqueryname;
$zz = @main::enterable_products; $zz = @main::enterable_products;
...@@ -1536,7 +1535,7 @@ sub GetFormat { ...@@ -1536,7 +1535,7 @@ sub GetFormat {
{ {
'template' => $template , 'template' => $template ,
'extension' => $ctype , 'extension' => $ctype ,
'ctype' => $::contenttypes->{$ctype} , 'ctype' => Bugzilla::Constants::contenttypes->{$ctype} ,
}; };
} }
......
...@@ -59,6 +59,8 @@ BEGIN { ...@@ -59,6 +59,8 @@ BEGIN {
chdir $::path; chdir $::path;
use lib ($::path); use lib ($::path);
use Bugzilla;
use XML::Parser; use XML::Parser;
use Data::Dumper; use Data::Dumper;
$Data::Dumper::Useqq = 1; $Data::Dumper::Useqq = 1;
...@@ -136,7 +138,7 @@ sub Lock { ...@@ -136,7 +138,7 @@ sub Lock {
open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!"; open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!";
my $val = flock(LOCKFID,2); my $val = flock(LOCKFID,2);
if (!$val) { # '2' is magic 'exclusive lock' const. if (!$val) { # '2' is magic 'exclusive lock' const.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
print "Lock failed: $val\n"; print "Lock failed: $val\n";
} }
chmod 0666, "data/maillock"; chmod 0666, "data/maillock";
......
...@@ -51,10 +51,12 @@ quietly_check_login('permit_anonymous'); ...@@ -51,10 +51,12 @@ quietly_check_login('permit_anonymous');
# Main Body Execution # Main Body Execution
############################################################################### ###############################################################################
my $cgi = Bugzilla->cgi;
$vars->{'username'} = $::COOKIE{'Bugzilla_login'} || ''; $vars->{'username'} = $::COOKIE{'Bugzilla_login'} || '';
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-Type: text/html\n\n"; print $cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("index.html.tmpl", $vars) $template->process("index.html.tmpl", $vars)
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
use strict; use strict;
use lib qw(.); use lib qw(.);
use Bugzilla;
require "CGI.pl"; require "CGI.pl";
use vars qw($userid @legal_keywords %FORM); use vars qw($userid @legal_keywords %FORM);
...@@ -37,6 +39,8 @@ quietly_check_login(); ...@@ -37,6 +39,8 @@ quietly_check_login();
GetVersionTable(); GetVersionTable();
my $cgi = Bugzilla->cgi;
my $generic_query = " my $generic_query = "
SELECT SELECT
bugs.bug_id, bugs.bug_id,
...@@ -116,8 +120,7 @@ my @time = localtime(time()); ...@@ -116,8 +120,7 @@ my @time = localtime(time());
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3]; my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
my $filename = "bugs-$date.html"; my $filename = "bugs-$date.html";
print "Content-Type: text/html\n"; print $cgi->header(-content_disposition => "inline; filename=$filename");
print "Content-Disposition: inline; filename=$filename\n\n";
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("bug/show-multiple.html.tmpl", $vars) $template->process("bug/show-multiple.html.tmpl", $vars)
......
...@@ -31,6 +31,7 @@ require "CGI.pl"; ...@@ -31,6 +31,7 @@ require "CGI.pl";
use vars qw($template $userid %COOKIE); use vars qw($template $userid %COOKIE);
use Bug; use Bug;
use Bugzilla;
use Bugzilla::BugMail; use Bugzilla::BugMail;
$::lockcount = 0; $::lockcount = 0;
...@@ -44,6 +45,8 @@ unless ( Param("move-enabled") ) { ...@@ -44,6 +45,8 @@ unless ( Param("move-enabled") ) {
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
my $cgi = Bugzilla->cgi;
sub Log { sub Log {
my ($str) = (@_); my ($str) = (@_);
Lock(); Lock();
...@@ -59,7 +62,7 @@ sub Lock { ...@@ -59,7 +62,7 @@ sub Lock {
open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!"; open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!";
my $val = flock(LOCKFID,2); my $val = flock(LOCKFID,2);
if (!$val) { # '2' is magic 'exclusive lock' const. if (!$val) { # '2' is magic 'exclusive lock' const.
print "Content-type: text/html\n\n"; print $cgi->header();
print "Lock failed: $val\n"; print "Lock failed: $val\n";
} }
chmod 0666, "data/maillock"; chmod 0666, "data/maillock";
...@@ -76,7 +79,7 @@ sub Unlock { ...@@ -76,7 +79,7 @@ sub Unlock {
} }
if ( !defined $::FORM{'buglist'} ) { if ( !defined $::FORM{'buglist'} ) {
print "Content-type: text/html\n\n"; print $cgi->header();
PutHeader("Move Bugs"); PutHeader("Move Bugs");
print "Move bugs either from the bug display page or perform a "; print "Move bugs either from the bug display page or perform a ";
print "<A HREF=\"query.cgi\">query</A> and change several bugs at once.\n"; print "<A HREF=\"query.cgi\">query</A> and change several bugs at once.\n";
...@@ -91,7 +94,7 @@ my $movers = Param("movers"); ...@@ -91,7 +94,7 @@ my $movers = Param("movers");
$movers =~ s/\s?,\s?/|/g; $movers =~ s/\s?,\s?/|/g;
$movers =~ s/@/\@/g; $movers =~ s/@/\@/g;
unless ($exporter =~ /($movers)/) { unless ($exporter =~ /($movers)/) {
print "Content-type: text/html\n\n"; print $cgi->header();
PutHeader("Move Bugs"); PutHeader("Move Bugs");
print "<P>You do not have permission to move bugs<P>\n"; print "<P>You do not have permission to move bugs<P>\n";
PutFooter(); PutFooter();
......
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
use strict; use strict;
use lib "."; use lib ".";
use Bugzilla;
require "CGI.pl"; require "CGI.pl";
use vars qw($template $vars); use vars qw($template $vars);
...@@ -39,6 +42,8 @@ ConnectToDatabase(); ...@@ -39,6 +42,8 @@ ConnectToDatabase();
quietly_check_login(); quietly_check_login();
my $cgi = Bugzilla->cgi;
if ($::FORM{'id'}) { if ($::FORM{'id'}) {
# Remove all dodgy chars, and split into name and ctype. # Remove all dodgy chars, and split into name and ctype.
$::FORM{'id'} =~ s/[^\w\-\.]//g; $::FORM{'id'} =~ s/[^\w\-\.]//g;
...@@ -47,8 +52,8 @@ if ($::FORM{'id'}) { ...@@ -47,8 +52,8 @@ if ($::FORM{'id'}) {
my $format = GetFormat($1, undef, $2); my $format = GetFormat($1, undef, $2);
$vars->{'form'} = \%::FORM; $vars->{'form'} = \%::FORM;
print "Content-Type: $format->{'ctype'}\n\n"; print $cgi->header($format->{'ctype'});
$template->process("pages/$format->{'template'}", $vars) $template->process("pages/$format->{'template'}", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
use strict; use strict;
use lib qw(.); use lib qw(.);
use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
require "CGI.pl"; require "CGI.pl";
...@@ -55,6 +56,8 @@ use vars qw($vars $template); ...@@ -55,6 +56,8 @@ use vars qw($vars $template);
ConnectToDatabase(); ConnectToDatabase();
my $whoid = confirm_login(); my $whoid = confirm_login();
my $cgi = Bugzilla->cgi;
# do a match on the fields if applicable # do a match on the fields if applicable
&Bugzilla::User::match_field ({ &Bugzilla::User::match_field ({
...@@ -85,16 +88,17 @@ if (!$product_id) { ...@@ -85,16 +88,17 @@ if (!$product_id) {
# Set cookies # Set cookies
my $cookiepath = Param("cookiepath"); my $cookiepath = Param("cookiepath");
if (exists $::FORM{'product'}) { if (exists $::FORM{'product'}) {
if (exists $::FORM{'version'}) { if (exists $::FORM{'version'}) {
print "Set-Cookie: VERSION-$product=$::FORM{'version'} ; " . $cgi->send_cookie(-name => "VERSION-$product",
"path=$cookiepath ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n"; -value => $cgi->param('version'),
-expires => "Fri, 01-Jan-2038 00:00:00 GMT");
} }
} }
if (defined $::FORM{'maketemplate'}) { if (defined $::FORM{'maketemplate'}) {
$vars->{'url'} = $::buffer; $vars->{'url'} = $::buffer;
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("bug/create/make-template.html.tmpl", $vars) $template->process("bug/create/make-template.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
...@@ -491,7 +495,7 @@ if ($::COOKIE{"BUGLIST"}) { ...@@ -491,7 +495,7 @@ if ($::COOKIE{"BUGLIST"}) {
} }
$vars->{'bug_list'} = \@bug_list; $vars->{'bug_list'} = \@bug_list;
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("bug/create/created.html.tmpl", $vars) $template->process("bug/create/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -31,6 +31,7 @@ my $UserInCanConfirmGroupSet = -1; ...@@ -31,6 +31,7 @@ my $UserInCanConfirmGroupSet = -1;
use lib qw(.); use lib qw(.);
use Bugzilla;
use Bugzilla::Constants; use Bugzilla::Constants;
require "CGI.pl"; require "CGI.pl";
...@@ -58,6 +59,8 @@ use vars qw(%versions ...@@ -58,6 +59,8 @@ use vars qw(%versions
ConnectToDatabase(); ConnectToDatabase();
my $whoid = confirm_login(); my $whoid = confirm_login();
my $cgi = Bugzilla->cgi;
my $requiremilestone = 0; my $requiremilestone = 0;
use vars qw($template $vars); use vars qw($template $vars);
...@@ -143,7 +146,7 @@ foreach my $field ("dependson", "blocked") { ...@@ -143,7 +146,7 @@ foreach my $field ("dependson", "blocked") {
# End Data/Security Validation # End Data/Security Validation
###################################################################### ######################################################################
print "Content-type: text/html\n\n"; print $cgi->header();
$vars->{'title_tag'} = "bug_processed"; $vars->{'title_tag'} = "bug_processed";
# Set the title if we can see a mid-air coming. This test may have false # Set the title if we can see a mid-air coming. This test may have false
...@@ -493,7 +496,7 @@ sub DuplicateUserConfirm { ...@@ -493,7 +496,7 @@ sub DuplicateUserConfirm {
# Confirm whether or not to add the reporter to the cc: list # Confirm whether or not to add the reporter to the cc: list
# of the original bug (the one this bug is being duped against). # of the original bug (the one this bug is being duped against).
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("bug/process/confirm-duplicate.html.tmpl", $vars) $template->process("bug/process/confirm-duplicate.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
......
...@@ -50,6 +50,9 @@ use vars qw( ...@@ -50,6 +50,9 @@ use vars qw(
); );
ConnectToDatabase(); ConnectToDatabase();
my $cgi = Bugzilla->cgi;
my $userid = 0; my $userid = 0;
if (defined $::FORM{"GoAheadAndLogIn"}) { if (defined $::FORM{"GoAheadAndLogIn"}) {
# We got here from a login page, probably from relogin.cgi. We better # We got here from a login page, probably from relogin.cgi. We better
...@@ -87,8 +90,8 @@ if ($userid) { ...@@ -87,8 +90,8 @@ if ($userid) {
"($userid, $qname, " . SqlQuote($value) . ")"); "($userid, $qname, " . SqlQuote($value) . ")");
} }
} }
print "Set-Cookie: $cookiename= ; path=" . Param("cookiepath") . $cgi->send_cookie(-name => $cookiename,
"; expires=Sun, 30-Jun-1980 00:00:00 GMT\n"; -expires => "Fri, 01-Jan-2038 00:00:00 GMT");
} }
} }
} }
...@@ -398,6 +401,8 @@ $vars->{'format'} = $::FORM{'format'}; ...@@ -398,6 +401,8 @@ $vars->{'format'} = $::FORM{'format'};
my $format = GetFormat("search/search", my $format = GetFormat("search/search",
$::FORM{'query_format'} || $::FORM{'format'}, $::FORM{'query_format'} || $::FORM{'format'},
$::FORM{'ctype'}); $::FORM{'ctype'});
print "Content-Type: $format->{'ctype'}\n\n";
print $cgi->header($format->{'ctype'});
$template->process($format->{'template'}, $vars) $template->process($format->{'template'}, $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -35,7 +35,7 @@ quietly_check_login(); ...@@ -35,7 +35,7 @@ quietly_check_login();
GetVersionTable(); GetVersionTable();
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
my $product = $::FORM{'product'}; my $product = $::FORM{'product'};
......
...@@ -39,6 +39,8 @@ require "CGI.pl"; ...@@ -39,6 +39,8 @@ require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
confirm_login(); confirm_login();
my $cgi = Bugzilla->cgi;
if (Param('enablequips') eq "off") { if (Param('enablequips') eq "off") {
ThrowUserError("quips_disabled"); ThrowUserError("quips_disabled");
} }
...@@ -129,6 +131,6 @@ if ($action eq "delete") { ...@@ -129,6 +131,6 @@ if ($action eq "delete") {
SendSQL("DELETE FROM quips WHERE quipid = $quipid"); SendSQL("DELETE FROM quips WHERE quipid = $quipid");
} }
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("list/quips.html.tmpl", $vars) $template->process("list/quips.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -37,6 +37,8 @@ require "CGI.pl"; ...@@ -37,6 +37,8 @@ require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
quietly_check_login(); quietly_check_login();
my $cgi = Bugzilla->cgi;
if ($::userid) { if ($::userid) {
# Even though we know the userid must match, we still check it in the # Even though we know the userid must match, we still check it in the
# SQL as a sanity check, since there is no locking here, and if # SQL as a sanity check, since there is no locking here, and if
...@@ -49,17 +51,17 @@ if ($::userid) { ...@@ -49,17 +51,17 @@ if ($::userid) {
"AND userid = $::userid"); "AND userid = $::userid");
} }
my $cookiepath = Param("cookiepath"); $cgi->send_cookie(-name => "Bugzilla_login",
print "Set-Cookie: Bugzilla_login= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT -expires => "Tue, 15-Sep-1998 21:49:00 GMT");
Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT $cgi->send_cookie(-name => "Bugzilla_logincookie",
"; -expires => "Tue, 15-Sep-1998 21:49:00 GMT");
delete $::COOKIE{"Bugzilla_login"}; delete $::COOKIE{"Bugzilla_login"};
$vars->{'message'} = "logged_out"; $vars->{'message'} = "logged_out";
$vars->{'user'} = {}; $vars->{'user'} = {};
print "Content-Type: text/html\n\n"; print $cgi->header();
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -26,15 +26,19 @@ use lib "."; ...@@ -26,15 +26,19 @@ use lib ".";
require "CGI.pl"; require "CGI.pl";
use vars qw($cgi $template $vars); use vars qw($template $vars);
use Bugzilla; use Bugzilla;
my $cgi = Bugzilla->cgi;
# Go straight back to query.cgi if we are adding a boolean chart. # Go straight back to query.cgi if we are adding a boolean chart.
if (grep(/^cmd-/, $cgi->param())) { if (grep(/^cmd-/, $cgi->param())) {
my $params = $cgi->canonicalise_query("format", "ctype"); my $params = $cgi->canonicalise_query("format", "ctype");
print "Location: query.cgi?format=" . $cgi->param('query_format') . my $location = "query.cgi?format=" . $cgi->param('query_format') .
($params ? "&$params" : "") . "\n\n"; ($params ? "&$params" : "") . "\n\n";
print $cgi->redirect($location);
exit; exit;
} }
...@@ -52,7 +56,7 @@ my $action = $cgi->param('action') || 'menu'; ...@@ -52,7 +56,7 @@ my $action = $cgi->param('action') || 'menu';
if ($action eq "menu") { if ($action eq "menu") {
# No need to do any searching in this case, so bail out early. # No need to do any searching in this case, so bail out early.
print "Content-Type: text/html\n\n"; print $cgi->header();
$template->process("reports/menu.html.tmpl", $vars) $template->process("reports/menu.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit; exit;
...@@ -276,8 +280,8 @@ $format->{'ctype'} = "text/html" if $::FORM{'debug'}; ...@@ -276,8 +280,8 @@ $format->{'ctype'} = "text/html" if $::FORM{'debug'};
my @time = localtime(time()); my @time = localtime(time());
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3]; my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
my $filename = "report-$date.$format->{extension}"; my $filename = "report-$date.$format->{extension}";
print "Content-Disposition: inline; filename=$filename\n"; print $cgi->header(-type => $format->{'ctype'},
print "Content-Type: $format->{'ctype'}\n\n"; -content_disposition => "inline; filename=$filename");
# Problems with this CGI are often due to malformed data. Setting debug=1 # Problems with this CGI are often due to malformed data. Setting debug=1
# prints out both data structures. # prints out both data structures.
......
...@@ -62,6 +62,8 @@ GetVersionTable(); ...@@ -62,6 +62,8 @@ GetVersionTable();
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
my $cgi = Bugzilla->cgi;
# We only want those products that the user has permissions for. # We only want those products that the user has permissions for.
my @myproducts; my @myproducts;
push( @myproducts, "-All-"); push( @myproducts, "-All-");
...@@ -69,7 +71,7 @@ push( @myproducts, GetSelectableProducts()); ...@@ -69,7 +71,7 @@ push( @myproducts, GetSelectableProducts());
if (! defined $FORM{'product'}) { if (! defined $FORM{'product'}) {
print "Content-type: text/html\n\n"; print $cgi->header();
PutHeader("Bug Charts"); PutHeader("Bug Charts");
choose_product(@myproducts); choose_product(@myproducts);
PutFooter(); PutFooter();
...@@ -93,10 +95,7 @@ if (! defined $FORM{'product'}) { ...@@ -93,10 +95,7 @@ if (! defined $FORM{'product'}) {
# This means that is OK to detaint # This means that is OK to detaint
trick_taint($FORM{'product'}); trick_taint($FORM{'product'});
# Output appropriate HTTP response headers print $cgi->header(-Content_Disposition=>'inline; filename=bugzilla_report.html');
print "Content-type: text/html\n";
# Changing attachment to inline to resolve 46897 - zach@zachlipton.com
print "Content-disposition: inline; filename=bugzilla_report.html\n\n";
PutHeader("Bug Charts"); PutHeader("Bug Charts");
......
...@@ -266,7 +266,7 @@ sub queue { ...@@ -266,7 +266,7 @@ sub queue {
$vars->{'types'} = \@types; $vars->{'types'} = \@types;
# Return the appropriate HTTP response headers. # Return the appropriate HTTP response headers.
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
$template->process("request/queue.html.tmpl", $vars) $template->process("request/queue.html.tmpl", $vars)
......
...@@ -51,7 +51,7 @@ ValidateBugID($::FORM{'id'}); ...@@ -51,7 +51,7 @@ ValidateBugID($::FORM{'id'});
$vars->{'bug_id'} = $::FORM{'id'}; $vars->{'bug_id'} = $::FORM{'id'};
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("bug/activity/show.html.tmpl", $vars) $template->process("bug/activity/show.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -24,14 +24,18 @@ use strict; ...@@ -24,14 +24,18 @@ use strict;
use lib qw(.); use lib qw(.);
use Bugzilla;
require "CGI.pl"; require "CGI.pl";
ConnectToDatabase(); ConnectToDatabase();
use vars qw($cgi $template $vars $userid); use vars qw($template $vars $userid);
use Bug; use Bug;
my $cgi = Bugzilla->cgi;
if ($::FORM{'GoAheadAndLogIn'}) { if ($::FORM{'GoAheadAndLogIn'}) {
confirm_login(); confirm_login();
} else { } else {
...@@ -44,7 +48,7 @@ my $single = !$cgi->param('format') ...@@ -44,7 +48,7 @@ my $single = !$cgi->param('format')
# If we don't have an ID, _AND_ we're only doing a single bug, then prompt # If we don't have an ID, _AND_ we're only doing a single bug, then prompt
if (!defined $cgi->param('id') && $single) { if (!defined $cgi->param('id') && $single) {
print "Content-type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("bug/choose.html.tmpl", $vars) || $template->process("bug/choose.html.tmpl", $vars) ||
ThrowTemplateError($template->error()); ThrowTemplateError($template->error());
exit; exit;
...@@ -100,6 +104,7 @@ foreach ($cgi->param("excludefield")) { ...@@ -100,6 +104,7 @@ foreach ($cgi->param("excludefield")) {
$vars->{'displayfields'} = \%displayfields; $vars->{'displayfields'} = \%displayfields;
print "Content-type: $format->{'ctype'}\n\n"; print $cgi->header($format->{'ctype'});
$template->process("$format->{'template'}", $vars) $template->process("$format->{'template'}", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -25,12 +25,16 @@ use strict; ...@@ -25,12 +25,16 @@ use strict;
use lib qw(.); use lib qw(.);
require "CGI.pl"; use Bugzilla;
use Bugzilla::Util;
my $cgi = Bugzilla->cgi;
my $id = $cgi->param('attach_id');
detaint_natural($id) if defined $id;
$id ||= "";
print $cgi->redirect(-location=>"attachment.cgi?id=$id&action=view",
-status=>'301 Permanent Redirect');
# Redirect to the new interface for displaying attachments.
detaint_natural($::FORM{'attach_id'}) if defined($::FORM{'attach_id'});
my $id = $::FORM{'attach_id'} || "";
print "Status: 301 Permanent Redirect\n";
print "Location: attachment.cgi?id=$id&action=view\n\n";
exit; exit;
...@@ -26,6 +26,7 @@ use strict; ...@@ -26,6 +26,7 @@ use strict;
use lib qw(.); use lib qw(.);
use File::Temp; use File::Temp;
use Bugzilla;
require "CGI.pl"; require "CGI.pl";
...@@ -33,6 +34,8 @@ ConnectToDatabase(); ...@@ -33,6 +34,8 @@ ConnectToDatabase();
quietly_check_login(); quietly_check_login();
my $cgi = Bugzilla->cgi;
# Connect to the shadow database if this installation is using one to improve # Connect to the shadow database if this installation is using one to improve
# performance. # performance.
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
...@@ -228,6 +231,6 @@ $vars->{'rankdir'} = $::FORM{'rankdir'}; ...@@ -228,6 +231,6 @@ $vars->{'rankdir'} = $::FORM{'rankdir'};
$vars->{'showsummary'} = $::FORM{'showsummary'}; $vars->{'showsummary'} = $::FORM{'showsummary'};
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("bug/dependency-graph.html.tmpl", $vars) $template->process("bug/dependency-graph.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -37,6 +37,8 @@ ConnectToDatabase(); ...@@ -37,6 +37,8 @@ ConnectToDatabase();
quietly_check_login(); quietly_check_login();
my $cgi = Bugzilla->cgi;
# Connect to the shadow database if this installation is using one to improve # Connect to the shadow database if this installation is using one to improve
# performance. # performance.
Bugzilla->switch_to_shadow_db(); Bugzilla->switch_to_shadow_db();
...@@ -95,7 +97,7 @@ $vars->{'maxdepth'} = $maxdepth; ...@@ -95,7 +97,7 @@ $vars->{'maxdepth'} = $maxdepth;
$vars->{'hide_resolved'} = $hide_resolved; $vars->{'hide_resolved'} = $hide_resolved;
$vars->{'canedit'} = UserInGroup("editbugs"); $vars->{'canedit'} = UserInGroup("editbugs");
print "Content-Type: text/html\n\n"; print $cgi->header();
$template->process("bug/dependency-tree.html.tmpl", $vars) $template->process("bug/dependency-tree.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -29,6 +29,8 @@ use vars qw( ...@@ -29,6 +29,8 @@ use vars qw(
ConnectToDatabase(); ConnectToDatabase();
quietly_check_login(); quietly_check_login();
my $cgi = Bugzilla->cgi;
############################################################################### ###############################################################################
# Main Body Execution # Main Body Execution
############################################################################### ###############################################################################
...@@ -63,13 +65,10 @@ if (defined $::COOKIE{'Bugzilla_login'}) { ...@@ -63,13 +65,10 @@ if (defined $::COOKIE{'Bugzilla_login'}) {
my $useragent = $ENV{HTTP_USER_AGENT}; my $useragent = $ENV{HTTP_USER_AGENT};
if ($useragent =~ m:Mozilla/([1-9][0-9]*):i && $1 >= 5 && $useragent !~ m/compatible/i) { if ($useragent =~ m:Mozilla/([1-9][0-9]*):i && $1 >= 5 && $useragent !~ m/compatible/i) {
print "Content-type: application/vnd.mozilla.xul+xml\n\n"; print $cgi->header("application/vnd.mozilla.xul+xml");
# Generate and return the XUL from the appropriate template. # Generate and return the XUL from the appropriate template.
$template->process("sidebar.xul.tmpl", $vars) $template->process("sidebar.xul.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} else { } else {
ThrowUserError("sidebar_supports_mozilla_only"); ThrowUserError("sidebar_supports_mozilla_only");
} }
...@@ -61,11 +61,6 @@ ...@@ -61,11 +61,6 @@
[% ELSIF error == "bug_error" %] [% ELSIF error == "bug_error" %]
Trying to retrieve bug [% bug.bug_id %] returned the error Trying to retrieve bug [% bug.bug_id %] returned the error
[% bug.error FILTER html %] [% bug.error FILTER html %]
[% ELSIF error == "cgi_error" %]
[% title = "CGI Error" %]
Bugzilla has had trouble interpreting your CGI request;
[%+ Param('browserbugmessage') %]
[% ELSIF error == "chart_data_not_generated" %] [% ELSIF error == "chart_data_not_generated" %]
The tool which gathers bug counts has not been run yet. The tool which gathers bug counts has not been run yet.
......
...@@ -31,6 +31,8 @@ use lib qw(.); ...@@ -31,6 +31,8 @@ use lib qw(.);
use vars qw($template $vars); use vars qw($template $vars);
use Bugzilla;
# Include the Bugzilla CGI and general utility library. # Include the Bugzilla CGI and general utility library.
require "CGI.pl"; require "CGI.pl";
...@@ -156,7 +158,7 @@ sub requestChangePassword { ...@@ -156,7 +158,7 @@ sub requestChangePassword {
$vars->{'message'} = "password_change_request"; $vars->{'message'} = "password_change_request";
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} }
...@@ -164,7 +166,7 @@ sub requestChangePassword { ...@@ -164,7 +166,7 @@ sub requestChangePassword {
sub confirmChangePassword { sub confirmChangePassword {
$vars->{'token'} = $::token; $vars->{'token'} = $::token;
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("account/password/set-forgotten-password.html.tmpl", $vars) $template->process("account/password/set-forgotten-password.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} }
...@@ -173,7 +175,7 @@ sub cancelChangePassword { ...@@ -173,7 +175,7 @@ sub cancelChangePassword {
$vars->{'message'} = "password_change_canceled"; $vars->{'message'} = "password_change_canceled";
Token::Cancel($::token, $vars->{'message'}); Token::Cancel($::token, $vars->{'message'});
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} }
...@@ -200,14 +202,14 @@ sub changePassword { ...@@ -200,14 +202,14 @@ sub changePassword {
$vars->{'message'} = "password_changed"; $vars->{'message'} = "password_changed";
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} }
sub confirmChangeEmail { sub confirmChangeEmail {
# Return HTTP response headers. # Return HTTP response headers.
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
$vars->{'token'} = $::token; $vars->{'token'} = $::token;
...@@ -249,7 +251,7 @@ sub changeEmail { ...@@ -249,7 +251,7 @@ sub changeEmail {
DeriveGroup($userid); DeriveGroup($userid);
# Return HTTP response headers. # Return HTTP response headers.
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
# Let the user know their email address has been changed. # Let the user know their email address has been changed.
...@@ -300,7 +302,7 @@ sub cancelChangeEmail { ...@@ -300,7 +302,7 @@ sub cancelChangeEmail {
SendSQL("UNLOCK TABLES"); SendSQL("UNLOCK TABLES");
# Return HTTP response headers. # Return HTTP response headers.
print "Content-Type: text/html\n\n"; print Bugzilla->cgi->header();
$template->process("global/message.html.tmpl", $vars) $template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
......
...@@ -24,6 +24,8 @@ use strict; ...@@ -24,6 +24,8 @@ use strict;
use lib qw(.); use lib qw(.);
use Bugzilla;
require "CGI.pl"; require "CGI.pl";
use RelationSet; use RelationSet;
...@@ -354,6 +356,8 @@ confirm_login(); ...@@ -354,6 +356,8 @@ confirm_login();
GetVersionTable(); GetVersionTable();
my $cgi = Bugzilla->cgi;
$vars->{'login'} = $::COOKIE{'Bugzilla_login'}; $vars->{'login'} = $::COOKIE{'Bugzilla_login'};
$vars->{'changes_saved'} = $::FORM{'dosave'}; $vars->{'changes_saved'} = $::FORM{'dosave'};
...@@ -390,7 +394,7 @@ SWITCH: for ($current_tab_name) { ...@@ -390,7 +394,7 @@ SWITCH: for ($current_tab_name) {
} }
# Generate and return the UI (HTML page) from the appropriate template. # Generate and return the UI (HTML page) from the appropriate template.
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("account/prefs/prefs.html.tmpl", $vars) $template->process("account/prefs/prefs.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
...@@ -26,14 +26,17 @@ ...@@ -26,14 +26,17 @@
use strict; use strict;
use lib "."; use lib ".";
require "CGI.pl"; use Bugzilla;
require "CGI.pl";
# Use global template variables # Use global template variables
use vars qw($template $vars); use vars qw($template $vars);
ConnectToDatabase(); ConnectToDatabase();
my $cgi = Bugzilla->cgi;
# If the action is show_bug, you need a bug_id. # If the action is show_bug, you need a bug_id.
# If the action is show_user, you can supply a userid to show the votes for # If the action is show_user, you can supply a userid to show the votes for
# another user, otherwise you see your own. # another user, otherwise you see your own.
...@@ -86,6 +89,8 @@ exit; ...@@ -86,6 +89,8 @@ exit;
# Display the names of all the people voting for this one bug. # Display the names of all the people voting for this one bug.
sub show_bug { sub show_bug {
my $cgi = Bugzilla->cgi;
my $bug_id = $::FORM{'bug_id'} my $bug_id = $::FORM{'bug_id'}
|| ThrowCodeError("missing_bug_id"); || ThrowCodeError("missing_bug_id");
...@@ -107,7 +112,7 @@ sub show_bug { ...@@ -107,7 +112,7 @@ sub show_bug {
$vars->{'users'} = \@users; $vars->{'users'} = \@users;
$vars->{'total'} = $total; $vars->{'total'} = $total;
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("bug/votes/list-for-bug.html.tmpl", $vars) $template->process("bug/votes/list-for-bug.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} }
...@@ -117,6 +122,8 @@ sub show_bug { ...@@ -117,6 +122,8 @@ sub show_bug {
sub show_user { sub show_user {
GetVersionTable(); GetVersionTable();
my $cgi = Bugzilla->cgi;
# If a bug_id is given, and we're editing, we'll add it to the votes list. # If a bug_id is given, and we're editing, we'll add it to the votes list.
my $bug_id = $::FORM{'bug_id'} || ""; my $bug_id = $::FORM{'bug_id'} || "";
...@@ -213,7 +220,7 @@ sub show_user { ...@@ -213,7 +220,7 @@ sub show_user {
$vars->{'voting_user'} = { "login" => $name }; $vars->{'voting_user'} = { "login" => $name };
$vars->{'products'} = \@products; $vars->{'products'} = \@products;
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("bug/votes/list-for-user.html.tmpl", $vars) $template->process("bug/votes/list-for-user.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
} }
...@@ -224,6 +231,8 @@ sub record_votes { ...@@ -224,6 +231,8 @@ sub record_votes {
# Begin Data/Security Validation # Begin Data/Security Validation
############################################################################ ############################################################################
my $cgi = Bugzilla->cgi;
# Build a list of bug IDs for which votes have been submitted. Votes # Build a list of bug IDs for which votes have been submitted. Votes
# are submitted in form fields in which the field names are the bug # are submitted in form fields in which the field names are the bug
# IDs and the field values are the number of votes. # IDs and the field values are the number of votes.
...@@ -233,13 +242,13 @@ sub record_votes { ...@@ -233,13 +242,13 @@ sub record_votes {
# that their votes will get nuked if they continue. # that their votes will get nuked if they continue.
if (scalar(@buglist) == 0) { if (scalar(@buglist) == 0) {
if (!defined($::FORM{'delete_all_votes'})) { if (!defined($::FORM{'delete_all_votes'})) {
print "Content-type: text/html\n\n"; print $cgi->header();
$template->process("bug/votes/delete-all.html.tmpl", $vars) $template->process("bug/votes/delete-all.html.tmpl", $vars)
|| ThrowTemplateError($template->error()); || ThrowTemplateError($template->error());
exit(); exit();
} }
elsif ($::FORM{'delete_all_votes'} == 0) { elsif ($::FORM{'delete_all_votes'} == 0) {
print "Location: votes.cgi\n\n"; print $cgi->redirect("votes.cgi");
exit(); exit();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment