undef,
$userid, $ipaddr);
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";
- print "Set-Cookie: Bugzilla_logincookie=$logincookie ; path=$cookiepath; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
+
+ $cgi->send_cookie(-name => 'Bugzilla_login',
+ -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
# isn't generic yet.
if ($authres == AUTH_NODATA && $type == LOGIN_REQUIRED) {
# Throw up the login page
- print "Content-Type: text/html\n\n";
+ print Bugzilla->cgi->header();
my $template = Bugzilla->template;
$template->process("account/auth/login.html.tmpl",
# The account may be disabled
if ($authres == AUTH_DISABLED) {
# Clear the cookie
- my $cookiepath = Param("cookiepath");
- print "Set-Cookie: Bugzilla_login= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT\n";
- print "Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT\n";
+
+ $cgi->send_cookie(-name => 'Bugzilla_login',
+ -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
&::ThrowUserError("account_disabled",
{'disabled_reason' => $extra});
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 Bugzilla::Util;
+use Bugzilla::Config;
# We need to disable output buffering - see bug 179174
$| = 1;
my $self = $class->SUPER::new(@args);
+ # Make sure that we don't send any charset headers
+ $self->charset('');
+
# Check for errors
# All of the Bugzilla code wants to do this, so do it here instead of
# in each script
# multipart requests, and so should never happen unless there is a
# browser bug.
- # Using CGI.pm to do this means that ThrowCodeError prints the
- # content-type again...
- #print $self->header(-status => $err);
- print "Status: $err\n";
-
- my $vars = {};
- if ($err =~ m/(\d{3})\s(.*)/) {
- $vars->{http_error_code} = $1;
- $vars->{http_error_string} = $2;
- } else {
- $vars->{http_error_string} = $err;
- }
-
- &::ThrowCodeError("cgi_error", $vars);
+ print $self->header(-status => $err);
+
+ # ThrowCodeError wants to print the header, so it grabs Bugzilla->cgi
+ # which creates a new Bugzilla::CGI object, which fails again, which
+ # ends up here, and calls ThrowCodeError, and then recurses forever.
+ # So don't use it.
+ # In fact, we can't use templates at all, because we need a CGI object
+ # to determine the template lang as well as the current url (from the
+ # template)
+ # Since this is an internal error which indicates a severe browser bug,
+ # just die.
+ die "CGI parsing error: $err";
}
return $self;
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;
__END__
This returns a sorted string of the parameters, suitable for use in a url.
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
+
+=head1 SEE ALSO
+
+L<CGI|CGI>, L<CGI::Cookie|CGI::Cookie>
LOGIN_NORMAL
LOGIN_REQUIRED
);
-
+
+@Bugzilla::Constants::EXPORT_OK = qw(contenttypes);
# CONSTANTS
#
use constant LOGIN_NORMAL => 1;
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;
Bugzilla->dbh->do("UNLOCK TABLES") if $unlock_tables;
- # XXX - mod_perl
- print "Content-type: text/html\n\n" if !$::vars->{'header_done'};
+ print Bugzilla->cgi->header();
my $template = Bugzilla->template;
$template->process("global/user-error.html.tmpl", $vars)
my $rv =
$::template->process($template_file, $::vars, \$message);
if (!$rv) {
- print "Content-Type: text/html\n\n" unless $::vars->{'header_done'};
+ Bugzilla->cgi->header();
&::ThrowTemplateError($::template->error());
}
$vars->{'matches'} = $matches; # matches that were made
$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)
|| &::ThrowTemplateError($::template->error());
$::vars->{'message'} = "shutdown";
# 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.
$::template->process("global/message.html.tmpl", $::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)
|| ThrowTemplateError($template->error());
use lib qw(.);
use vars qw(
- $cgi
$template
$vars
);
# to just above validateID().
my $bugid;
+my $cgi = Bugzilla->cgi;
+
################################################################################
# Main Body Execution
################################################################################
# Return the appropriate HTTP response headers.
$filename =~ s/^.*[\/\\]//;
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;
}
$vars->{'bugsummary'} = $bugsummary;
$vars->{'GetBugLink'} = \&GetBugLink;
- # 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.
$template->process("attachment/show-multiple.html.tmpl", $vars)
$vars->{'bugsummary'} = $bugsummary;
$vars->{'GetBugLink'} = \&GetBugLink;
- # 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.
$template->process("attachment/create.html.tmpl", $vars)
$vars->{'contenttypemethod'} = $::FORM{'contenttypemethod'};
$vars->{'contenttype'} = $::FORM{'contenttype'};
- # 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.
$template->process("attachment/created.html.tmpl", $vars)
$vars->{'attachments'} = \@bugattachments;
$vars->{'GetBugLink'} = \&GetBugLink;
- # 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.
$template->process("attachment/edit.html.tmpl", $vars)
$vars->{'attachid'} = $::FORM{'id'};
$vars->{'bugid'} = $bugid;
- # 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.
$template->process("attachment/updated.html.tmpl", $vars)
use lib qw(.);
-use vars qw($cgi $template $vars);
+use vars qw($template $vars);
use Bugzilla;
use Bugzilla::Search;
$userid
@versions);
+my $cgi = Bugzilla->cgi;
+
if (length($::buffer) == 0) {
- print "Refresh: 10; URL=query.cgi\n";
+ print $cgi->header(-refresh=> '10; URL=query.cgi');
ThrowUserError("buglist_parameters_required");
-}
+}
ConnectToDatabase();
if ($::buffer =~ /&cmd-/) {
my $url = "query.cgi?$::buffer#chart";
- print "Refresh: 0; URL=$url\n";
- print "Content-Type: text/html\n\n";
+ print $cgi->redirect(-location => $url);
# Generate and return the UI (HTML page) from the appropriate template.
$vars->{'message'} = "buglist_adding_field";
$vars->{'url'} = $url;
}
elsif ($::FORM{'remaction'} eq "load") {
my $url = "query.cgi?" . LookupNamedQuery($::FORM{"namedcmd"});
- print "Refresh: 0; URL=$url\n";
- print "Content-Type: text/html\n\n";
+ print $cgi->redirect(-location=>$url);
# Generate and return the UI (HTML page) from the appropriate template.
$vars->{'message'} = "buglist_load_named_query";
$vars->{'namedcmd'} = $::FORM{'namedcmd'};
$count++;
}
- print "Content-Type: text/html\n\n";
+ print $cgi->header();
# Generate and return the UI (HTML page) from the appropriate template.
$vars->{'message'} = "buglist_query_gone";
$vars->{'namedcmd'} = $::FORM{'namedcmd'};
if (!grep($fragment =~ /^\Q$_\E(\s+(asc|desc))?$/, @columnnames)) {
$vars->{'fragment'} = $fragment;
if ($order_from_cookie) {
- my $cookiepath = Param("cookiepath");
- print "Set-Cookie: LASTORDER= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT\n";
+ $cgi->send_cookie(-name => 'LASTORDER',
+ -expires => 'Tue, 15-Sep-1998 21:49:00 GMT');
ThrowCodeError("invalid_column_name_cookie");
}
else {
# Time to use server push to display an interim message to the user until
# the query completes and we can display the bug list.
if ($serverpush) {
- # Generate HTTP headers.
- print "Content-Disposition: inline; filename=$filename\n";
- print "Content-Type: multipart/x-mixed-replace;boundary=thisrandomstring\n\n";
- print "--thisrandomstring\n";
- print "Content-Type: text/html\n\n";
+ print $cgi->multipart_init(-content_disposition => "inline; filename=$filename");
+
+ print $cgi->multipart_start();
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("list/server-push.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
+
+ print $cgi->multipart_end();
}
# Connect to the shadow database if this installation is using one to improve
# HTTP Header Generation
################################################################################
-# If we are doing server push, output a separator string.
-print "\n--thisrandomstring\n" if $serverpush;
-
# Generate HTTP headers
-# 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 "Content-Disposition: inline; filename=$filename\n" unless $serverpush;
+my $contenttype;
if ($format->{'extension'} eq "html") {
my $cookiepath = Param("cookiepath");
- print "Content-Type: text/html\n";
if ($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);
# See also Bug 111999
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 {
- 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;
}
+
+ $contenttype = "text/html";
}
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");
+}
################################################################################
# Script Conclusion
################################################################################
-print "\n--thisrandomstring--\n" if $serverpush;
+print $cgi->multipart_final() if $serverpush;
},
{
name => 'CGI',
- version => '2.88'
+ version => '2.93'
},
{
name => 'Data::Dumper',
);
');
-
-
-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 "") {
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",
$vars
);
+use Bugzilla;
+
require "CGI.pl";
ConnectToDatabase();
GetVersionTable();
+my $cgi = Bugzilla->cgi;
+
# The master list not only says what fields are possible, but what order
# they get displayed in.
my @masterlist = ("opendate", "changeddate", "bug_severity", "priority",
}
my $list = join(" ", @collist);
my $urlbase = Param("urlbase");
- my $cookiepath = Param("cookiepath");
-
- print "Set-Cookie: COLUMNLIST=$list ; path=$cookiepath ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
- print "Set-Cookie: SPLITHEADER=$::FORM{'splitheader'} ; path=$cookiepath ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
- print "Refresh: 0; URL=buglist.cgi?$::FORM{'rememberedquery'}\n";
- print "Content-type: text/html\n\n";
+
+ $cgi->send_cookie(-name => 'COLUMNLIST',
+ -value => $list,
+ -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
+ $cgi->send_cookie(-name => 'SPLITHEADER',
+ -value => $::FORM{'splitheader'},
+ -expires => 'Fri, 01-Jan-2038 00:00:00 GMT');
+
+ print $cgi->redirect("buglist.cgi?$::FORM{'rememberedquery'}");
$vars->{'message'} = "change_columns";
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
$vars->{'buffer'} = $::buffer;
# 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)
|| ThrowTemplateError($template->error());
ThrowUserError("auth_cant_create_account");
}
+my $cgi = Bugzilla->cgi;
+
# Clear out the login cookies. Make people log in again if they create an
# account; otherwise, they'll probably get confused.
-my $cookiepath = Param("cookiepath");
-print "Set-Cookie: Bugzilla_login= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT
-Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT\n";
+$cgi->send_cookie(-name => 'Bugzilla_login',
+ -expires => 'Tue, 15-Sep-1998 21:49:00 GMT');
+$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'};
use lib qw(.);
+use Bugzilla;
+
require "CGI.pl";
ConnectToDatabase();
GetVersionTable();
+my $cgi = Bugzilla->cgi;
+
if (!defined $::FORM{'product'}) {
# Reference to a subset of %::proddesc, which the user is allowed to see
my %products;
$::vars->{'proddesc'} = \%products;
$::vars->{'target'} = "describecomponents.cgi";
- print "Content-type: text/html\n\n";
+ print $cgi->header();
$::template->process("global/choose-product.html.tmpl", $::vars)
|| ThrowTemplateError($::template->error());
exit;
$::vars->{'product'} = $product;
$::vars->{'components'} = \@components;
-print "Content-type: text/html\n\n";
+print $cgi->header();
$::template->process("reports/components.html.tmpl", $::vars)
|| ThrowTemplateError($::template->error());
use strict;
use lib ".";
+use Bugzilla;
+
require "CGI.pl";
# Use the global template variables.
quietly_check_login();
+my $cgi = Bugzilla->cgi;
+
SendSQL("SELECT keyworddefs.name, keyworddefs.description,
COUNT(keywords.bug_id)
FROM keyworddefs LEFT JOIN keywords ON keyworddefs.id=keywords.keywordid
$vars->{'keywords'} = \@keywords;
$vars->{'caneditkeywords'} = UserInGroup("editkeywords");
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
$template->process("reports/keywords.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
use lib qw(.);
+use Bugzilla;
use Bugzilla::Config qw(:DEFAULT :admin);
require "CGI.pl";
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+my $cgi = Bugzilla->cgi;
+
+print $cgi->header();
if (!UserInGroup("tweakparams")) {
print "<H1>Sorry, you aren't a member of the 'tweakparams' group.</H1>\n";
use Bugzilla;
use Bugzilla::Search;
-use Bugzilla::CGI;
+
+my $cgi = Bugzilla->cgi;
# 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
# the user to a signed copy of the script in duplicates.jar if it exists.
if ($::FORM{'ctype'} && $::FORM{'ctype'} eq "xul") {
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";
+
+ print $cgi->redirect($url);
exit;
}
my $format =
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.
$template->process($format->{'template'}, $vars)
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
unless (UserInGroup("editcomponents")) {
PutHeader("Not allowed");
ConnectToDatabase();
# Use Bugzilla's flag modules for handling flag types.
+use Bugzilla;
use Bugzilla::Flag;
use Bugzilla::FlagType;
Bugzilla::FlagType::match({ 'target_type' => 'attachment' }, 1);
# 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.
$template->process("admin/flag-type/list.html.tmpl", $vars)
}
# 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.
$template->process("admin/flag-type/edit.html.tmpl", $vars)
$vars->{'type'} = $type;
# 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.
$template->process("admin/flag-type/edit.html.tmpl", $vars)
$vars->{'message'} = "flag_type_created";
# 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.
$template->process("global/message.html.tmpl", $vars)
$vars->{'message'} = "flag_type_changes_saved";
# 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.
$template->process("global/message.html.tmpl", $vars)
$vars->{'flag_count'} = scalar($count);
# 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.
$template->process("admin/flag-type/confirm-delete.html.tmpl", $vars)
$vars->{'message'} = "flag_type_deleted";
# 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.
$template->process("global/message.html.tmpl", $vars)
$vars->{'flag_type'} = Bugzilla::FlagType::get($::FORM{'id'});
# 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.
$template->process("global/message.html.tmpl", $vars)
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
if (!UserInGroup("creategroups")) {
PutHeader("Not Authorized","Edit Groups","","Not Authorized for this function!");
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
unless (UserInGroup("editkeywords")) {
PutHeader("Not allowed");
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
unless (UserInGroup("editcomponents")) {
PutHeader("Not allowed");
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
if (!UserInGroup("tweakparams")) {
print "<H1>Sorry, you aren't a member of the 'tweakparams' group.</H1>\n";
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
unless (UserInGroup("editcomponents")) {
PutHeader("Not allowed");
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
$editall = UserInGroup("editusers");
ConnectToDatabase();
confirm_login();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
unless (UserInGroup("editcomponents")) {
PutHeader("Not allowed");
use lib qw(.);
+use Bugzilla;
use Bugzilla::Constants;
require "CGI.pl";
# user is right from the start.
confirm_login() if AnyEntryGroups();
+my $cgi = Bugzilla->cgi;
+
if (!defined $::FORM{'product'}) {
GetVersionTable();
quietly_check_login();
$vars->{'target'} = "enter_bug.cgi";
$vars->{'format'} = $::FORM{'format'};
- print "Content-type: text/html\n\n";
+ print $cgi->header();
$template->process("global/choose-product.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
my $format =
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)
|| ThrowTemplateError($template->error());
sub globals_pl_sillyness {
my $zz;
$zz = @main::SqlStateStack;
- $zz = $main::contenttypes;
$zz = @main::default_column_list;
$zz = $main::defaultqueryname;
$zz = @main::enterable_products;
{
'template' => $template ,
'extension' => $ctype ,
- 'ctype' => $::contenttypes->{$ctype} ,
+ 'ctype' => Bugzilla::Constants::contenttypes->{$ctype} ,
};
}
chdir $::path;
use lib ($::path);
+use Bugzilla;
+
use XML::Parser;
use Data::Dumper;
$Data::Dumper::Useqq = 1;
open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!";
my $val = flock(LOCKFID,2);
if (!$val) { # '2' is magic 'exclusive lock' const.
- print "Content-type: text/html\n\n";
+ print Bugzilla->cgi->header();
print "Lock failed: $val\n";
}
chmod 0666, "data/maillock";
# Main Body Execution
###############################################################################
+my $cgi = Bugzilla->cgi;
+
$vars->{'username'} = $::COOKIE{'Bugzilla_login'} || '';
# 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.
$template->process("index.html.tmpl", $vars)
use strict;
use lib qw(.);
+use Bugzilla;
+
require "CGI.pl";
use vars qw($userid @legal_keywords %FORM);
GetVersionTable();
+my $cgi = Bugzilla->cgi;
+
my $generic_query = "
SELECT
bugs.bug_id,
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
my $filename = "bugs-$date.html";
-print "Content-Type: text/html\n";
-print "Content-Disposition: inline; filename=$filename\n\n";
+print $cgi->header(-content_disposition => "inline; filename=$filename");
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("bug/show-multiple.html.tmpl", $vars)
use vars qw($template $userid %COOKIE);
use Bug;
+use Bugzilla;
use Bugzilla::BugMail;
$::lockcount = 0;
ConnectToDatabase();
confirm_login();
+my $cgi = Bugzilla->cgi;
+
sub Log {
my ($str) = (@_);
Lock();
open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!";
my $val = flock(LOCKFID,2);
if (!$val) { # '2' is magic 'exclusive lock' const.
- print "Content-type: text/html\n\n";
+ print $cgi->header();
print "Lock failed: $val\n";
}
chmod 0666, "data/maillock";
}
if ( !defined $::FORM{'buglist'} ) {
- print "Content-type: text/html\n\n";
+ print $cgi->header();
PutHeader("Move Bugs");
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";
$movers =~ s/\s?,\s?/|/g;
$movers =~ s/@/\@/g;
unless ($exporter =~ /($movers)/) {
- print "Content-type: text/html\n\n";
+ print $cgi->header();
PutHeader("Move Bugs");
print "<P>You do not have permission to move bugs<P>\n";
PutFooter();
use strict;
use lib ".";
+
+use Bugzilla;
+
require "CGI.pl";
use vars qw($template $vars);
quietly_check_login();
+my $cgi = Bugzilla->cgi;
+
if ($::FORM{'id'}) {
# Remove all dodgy chars, and split into name and ctype.
$::FORM{'id'} =~ s/[^\w\-\.]//g;
my $format = GetFormat($1, undef, $2);
$vars->{'form'} = \%::FORM;
-
- print "Content-Type: $format->{'ctype'}\n\n";
+
+ print $cgi->header($format->{'ctype'});
$template->process("pages/$format->{'template'}", $vars)
|| ThrowTemplateError($template->error());
use strict;
use lib qw(.);
+use Bugzilla;
use Bugzilla::Constants;
require "CGI.pl";
ConnectToDatabase();
my $whoid = confirm_login();
+my $cgi = Bugzilla->cgi;
+
# do a match on the fields if applicable
&Bugzilla::User::match_field ({
# Set cookies
my $cookiepath = Param("cookiepath");
if (exists $::FORM{'product'}) {
- if (exists $::FORM{'version'}) {
- print "Set-Cookie: VERSION-$product=$::FORM{'version'} ; " .
- "path=$cookiepath ; expires=Sun, 30-Jun-2029 00:00:00 GMT\n";
+ if (exists $::FORM{'version'}) {
+ $cgi->send_cookie(-name => "VERSION-$product",
+ -value => $cgi->param('version'),
+ -expires => "Fri, 01-Jan-2038 00:00:00 GMT");
}
}
if (defined $::FORM{'maketemplate'}) {
$vars->{'url'} = $::buffer;
- print "Content-type: text/html\n\n";
+ print $cgi->header();
$template->process("bug/create/make-template.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}
$vars->{'bug_list'} = \@bug_list;
-print "Content-type: text/html\n\n";
+print $cgi->header();
$template->process("bug/create/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
use lib qw(.);
+use Bugzilla;
use Bugzilla::Constants;
require "CGI.pl";
ConnectToDatabase();
my $whoid = confirm_login();
+my $cgi = Bugzilla->cgi;
+
my $requiremilestone = 0;
use vars qw($template $vars);
# End Data/Security Validation
######################################################################
-print "Content-type: text/html\n\n";
+print $cgi->header();
$vars->{'title_tag'} = "bug_processed";
# Set the title if we can see a mid-air coming. This test may have false
# Confirm whether or not to add the reporter to the cc: list
# 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)
|| ThrowTemplateError($template->error());
exit;
);
ConnectToDatabase();
+
+my $cgi = Bugzilla->cgi;
+
my $userid = 0;
if (defined $::FORM{"GoAheadAndLogIn"}) {
# We got here from a login page, probably from relogin.cgi. We better
"($userid, $qname, " . SqlQuote($value) . ")");
}
}
- print "Set-Cookie: $cookiename= ; path=" . Param("cookiepath") .
- "; expires=Sun, 30-Jun-1980 00:00:00 GMT\n";
+ $cgi->send_cookie(-name => $cookiename,
+ -expires => "Fri, 01-Jan-2038 00:00:00 GMT");
}
}
}
my $format = GetFormat("search/search",
$::FORM{'query_format'} || $::FORM{'format'},
$::FORM{'ctype'});
-print "Content-Type: $format->{'ctype'}\n\n";
+
+print $cgi->header($format->{'ctype'});
+
$template->process($format->{'template'}, $vars)
|| ThrowTemplateError($template->error());
GetVersionTable();
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
my $product = $::FORM{'product'};
ConnectToDatabase();
confirm_login();
+my $cgi = Bugzilla->cgi;
+
if (Param('enablequips') eq "off") {
ThrowUserError("quips_disabled");
}
SendSQL("DELETE FROM quips WHERE quipid = $quipid");
}
-print "Content-type: text/html\n\n";
+print $cgi->header();
$template->process("list/quips.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
ConnectToDatabase();
quietly_check_login();
+my $cgi = Bugzilla->cgi;
+
if ($::userid) {
# 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
"AND userid = $::userid");
}
-my $cookiepath = Param("cookiepath");
-print "Set-Cookie: Bugzilla_login= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT
-Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00:00:00 GMT
-";
+$cgi->send_cookie(-name => "Bugzilla_login",
+ -expires => "Tue, 15-Sep-1998 21:49:00 GMT");
+$cgi->send_cookie(-name => "Bugzilla_logincookie",
+ -expires => "Tue, 15-Sep-1998 21:49:00 GMT");
delete $::COOKIE{"Bugzilla_login"};
-$vars->{'message'} = "logged_out";
+$vars->{'message'} = "logged_out";
$vars->{'user'} = {};
-print "Content-Type: text/html\n\n";
+print $cgi->header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
require "CGI.pl";
-use vars qw($cgi $template $vars);
+use vars qw($template $vars);
use Bugzilla;
+my $cgi = Bugzilla->cgi;
+
# Go straight back to query.cgi if we are adding a boolean chart.
if (grep(/^cmd-/, $cgi->param())) {
my $params = $cgi->canonicalise_query("format", "ctype");
- print "Location: query.cgi?format=" . $cgi->param('query_format') .
- ($params ? "&$params" : "") . "\n\n";
+ my $location = "query.cgi?format=" . $cgi->param('query_format') .
+ ($params ? "&$params" : "") . "\n\n";
+
+ print $cgi->redirect($location);
exit;
}
if ($action eq "menu") {
# 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)
|| ThrowTemplateError($template->error());
exit;
my @time = localtime(time());
my $date = sprintf "%04d-%02d-%02d", 1900+$time[5],$time[4]+1,$time[3];
my $filename = "report-$date.$format->{extension}";
-print "Content-Disposition: inline; filename=$filename\n";
-print "Content-Type: $format->{'ctype'}\n\n";
+print $cgi->header(-type => $format->{'ctype'},
+ -content_disposition => "inline; filename=$filename");
# Problems with this CGI are often due to malformed data. Setting debug=1
# prints out both data structures.
Bugzilla->switch_to_shadow_db();
+my $cgi = Bugzilla->cgi;
+
# We only want those products that the user has permissions for.
my @myproducts;
push( @myproducts, "-All-");
if (! defined $FORM{'product'}) {
- print "Content-type: text/html\n\n";
+ print $cgi->header();
PutHeader("Bug Charts");
choose_product(@myproducts);
PutFooter();
# This means that is OK to detaint
trick_taint($FORM{'product'});
- # Output appropriate HTTP response headers
- 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";
+ print $cgi->header(-Content_Disposition=>'inline; filename=bugzilla_report.html');
PutHeader("Bug Charts");
$vars->{'types'} = \@types;
# 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.
$template->process("request/queue.html.tmpl", $vars)
$vars->{'bug_id'} = $::FORM{'id'};
-print "Content-type: text/html\n\n";
+print Bugzilla->cgi->header();
$template->process("bug/activity/show.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
use lib qw(.);
+use Bugzilla;
+
require "CGI.pl";
ConnectToDatabase();
-use vars qw($cgi $template $vars $userid);
+use vars qw($template $vars $userid);
use Bug;
+my $cgi = Bugzilla->cgi;
+
if ($::FORM{'GoAheadAndLogIn'}) {
confirm_login();
} else {
# If we don't have an ID, _AND_ we're only doing a single bug, then prompt
if (!defined $cgi->param('id') && $single) {
- print "Content-type: text/html\n\n";
+ print Bugzilla->cgi->header();
$template->process("bug/choose.html.tmpl", $vars) ||
ThrowTemplateError($template->error());
exit;
$vars->{'displayfields'} = \%displayfields;
-print "Content-type: $format->{'ctype'}\n\n";
+print $cgi->header($format->{'ctype'});
+
$template->process("$format->{'template'}", $vars)
|| ThrowTemplateError($template->error());
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;
-
use lib qw(.);
use File::Temp;
+use Bugzilla;
require "CGI.pl";
quietly_check_login();
+my $cgi = Bugzilla->cgi;
+
# Connect to the shadow database if this installation is using one to improve
# performance.
Bugzilla->switch_to_shadow_db();
$vars->{'showsummary'} = $::FORM{'showsummary'};
# 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)
|| ThrowTemplateError($template->error());
quietly_check_login();
+my $cgi = Bugzilla->cgi;
+
# Connect to the shadow database if this installation is using one to improve
# performance.
Bugzilla->switch_to_shadow_db();
$vars->{'hide_resolved'} = $hide_resolved;
$vars->{'canedit'} = UserInGroup("editbugs");
-print "Content-Type: text/html\n\n";
+print $cgi->header();
$template->process("bug/dependency-tree.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
ConnectToDatabase();
quietly_check_login();
+my $cgi = Bugzilla->cgi;
+
###############################################################################
# Main Body Execution
###############################################################################
my $useragent = $ENV{HTTP_USER_AGENT};
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.
$template->process("sidebar.xul.tmpl", $vars)
|| ThrowTemplateError($template->error());
} else {
ThrowUserError("sidebar_supports_mozilla_only");
}
-
-
-
[% ELSIF error == "bug_error" %]
Trying to retrieve bug [% bug.bug_id %] returned the error
[% 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" %]
The tool which gathers bug counts has not been run yet.
use vars qw($template $vars);
+use Bugzilla;
+
# Include the Bugzilla CGI and general utility library.
require "CGI.pl";
$vars->{'message'} = "password_change_request";
- print "Content-Type: text/html\n\n";
+ print Bugzilla->cgi->header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
sub confirmChangePassword {
$vars->{'token'} = $::token;
- print "Content-Type: text/html\n\n";
+ print Bugzilla->cgi->header();
$template->process("account/password/set-forgotten-password.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
$vars->{'message'} = "password_change_canceled";
Token::Cancel($::token, $vars->{'message'});
- print "Content-Type: text/html\n\n";
+ print Bugzilla->cgi->header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
$vars->{'message'} = "password_changed";
- print "Content-Type: text/html\n\n";
+ print Bugzilla->cgi->header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
sub confirmChangeEmail {
# Return HTTP response headers.
- print "Content-Type: text/html\n\n";
+ print Bugzilla->cgi->header();
$vars->{'token'} = $::token;
DeriveGroup($userid);
# 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.
SendSQL("UNLOCK TABLES");
# Return HTTP response headers.
- print "Content-Type: text/html\n\n";
+ print Bugzilla->cgi->header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
use lib qw(.);
+use Bugzilla;
+
require "CGI.pl";
use RelationSet;
GetVersionTable();
+my $cgi = Bugzilla->cgi;
+
$vars->{'login'} = $::COOKIE{'Bugzilla_login'};
$vars->{'changes_saved'} = $::FORM{'dosave'};
}
# 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)
|| ThrowTemplateError($template->error());
use strict;
use lib ".";
-require "CGI.pl";
+use Bugzilla;
+require "CGI.pl";
# Use global template variables
use vars qw($template $vars);
ConnectToDatabase();
+my $cgi = Bugzilla->cgi;
+
# 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
# another user, otherwise you see your own.
# Display the names of all the people voting for this one bug.
sub show_bug {
+ my $cgi = Bugzilla->cgi;
+
my $bug_id = $::FORM{'bug_id'}
|| ThrowCodeError("missing_bug_id");
$vars->{'users'} = \@users;
$vars->{'total'} = $total;
- print "Content-type: text/html\n\n";
+ print $cgi->header();
$template->process("bug/votes/list-for-bug.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
sub show_user {
GetVersionTable();
+ my $cgi = Bugzilla->cgi;
+
# If a bug_id is given, and we're editing, we'll add it to the votes list.
my $bug_id = $::FORM{'bug_id'} || "";
$vars->{'voting_user'} = { "login" => $name };
$vars->{'products'} = \@products;
- print "Content-type: text/html\n\n";
+ print $cgi->header();
$template->process("bug/votes/list-for-user.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
# Begin Data/Security Validation
############################################################################
+ my $cgi = Bugzilla->cgi;
+
# 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
# IDs and the field values are the number of votes.
# that their votes will get nuked if they continue.
if (scalar(@buglist) == 0) {
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)
|| ThrowTemplateError($template->error());
exit();
}
elsif ($::FORM{'delete_all_votes'} == 0) {
- print "Location: votes.cgi\n\n";
+ print $cgi->redirect("votes.cgi");
exit();
}
}