diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/CGI.pm | 9 | ||||
-rw-r--r-- | Bugzilla/Util.pm | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 6f5a6f6d7..c2d61780f 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -25,9 +25,18 @@ use strict; package Bugzilla::CGI; +BEGIN { + if ($^O =~ /MSWin32/i) { + # Help CGI find the correct temp directory as the default list + # isn't Windows friendly (Bug 248988) + $ENV{'TMPDIR'} = $ENV{'TEMP'} || $ENV{'TMP'} || "$ENV{'WINDIR'}\\TEMP"; + } +} + use CGI qw(-no_xhtml -oldstyle_urls :private_tempfiles :unique_headers SERVER_PUSH); use base qw(CGI); +use CGI::Carp qw(fatalsToBrowser); use Bugzilla::Error; use Bugzilla::Util; diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 83c9bf7d3..1ac25d1aa 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -33,6 +33,7 @@ use base qw(Exporter); detaint_signed html_quote url_quote value_quote xml_quote css_class_quote + i_am_cgi lsearch max min diff_arrays diff_strings trim wrap_comment find_wrap_point @@ -130,6 +131,12 @@ sub xml_quote { return $var; } +sub i_am_cgi () { + # I use SERVER_SOFTWARE because it's required to be + # defined for all requests in the CGI spec. + return exists $ENV{'SERVER_SOFTWARE'} ? 1 : 0; +} + sub lsearch { my ($list,$item) = (@_); my $count = 0; @@ -376,6 +383,9 @@ Bugzilla::Util - Generic utility functions for bugzilla value_quote($var); xml_quote($var); + # Functions that tell you about your environment + my $is_cgi = i_am_cgi(); + # Functions for searching $loc = lsearch(\@arr, $val); $val = max($a, $b, $c); @@ -480,6 +490,12 @@ This is similar to C<html_quote>, except that ' is escaped to '. This is kept separate from html_quote partly for compatibility with previous code (for ') and partly for future handling of non-ASCII characters. +=item C<i_am_cgi()> + +Tells you whether or not you are being run as a CGI script in a web +server. For example, it would return false if the caller is running +in a command-line script. + =back =head2 Searching |