summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Util.pm
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-07-14 15:01:34 +0200
committermkanat%kerio.com <>2005-07-14 15:01:34 +0200
commitbcfde177dbb9f3748f59af067357e5902335ca46 (patch)
tree9b889e93b023cc3a275867f1fd87571888353d25 /Bugzilla/Util.pm
parentbf0a551fc3ff716b540dc221ab58f80cc2b3d820 (diff)
downloadbugzilla-bcfde177dbb9f3748f59af067357e5902335ca46.tar.gz
bugzilla-bcfde177dbb9f3748f59af067357e5902335ca46.tar.xz
Bug 283989: CGI.pl global init code should be moved to Bugzilla::CGI
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wurblzap, a=justdave
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r--Bugzilla/Util.pm16
1 files changed, 16 insertions, 0 deletions
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 &apos;. This
is kept separate from html_quote partly for compatibility with previous code
(for &apos;) 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