From 383d469918839a9588c039aef0f36c989139c82e Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" <> Date: Fri, 26 Apr 2002 02:43:50 +0000 Subject: Bug 140110 - remove 273 lines of redundant code from CGI.pl. Patch by gerv; 2xr=ddk. --- CGI.pl | 270 +---------------------------------------------------------------- 1 file changed, 3 insertions(+), 267 deletions(-) (limited to 'CGI.pl') diff --git a/CGI.pl b/CGI.pl index 983513306..f9892f7c6 100644 --- a/CGI.pl +++ b/CGI.pl @@ -73,29 +73,10 @@ if (Param("shutdownhtml") && $0 !~ m:[\\/](do)?editparams.cgi$:) { exit; } -sub GeneratePersonInput { - my ($field, $required, $def_value, $extraJavaScript) = (@_); - $extraJavaScript ||= ""; - if ($extraJavaScript ne "") { - $extraJavaScript = "onChange=\"$extraJavaScript\""; - } - return ""; -} - -sub GeneratePeopleInput { - my ($field, $def_value) = (@_); - return ""; -} - - - - # Implementations of several of the below were blatently stolen from CGI.pm, # by Lincoln D. Stein. - # Get rid of all the %xx encoding and the like from the given URL. - sub url_decode { my ($todecode) = (@_); $todecode =~ tr/+/ /; # pluses become spaces @@ -103,16 +84,13 @@ sub url_decode { return $todecode; } - # Quotify a string, suitable for putting into a URL. - sub url_quote { my($toencode) = (@_); $toencode=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg; return $toencode; } - sub ParseUrlString { # We don't want to detaint the user supplied data... use re 'taint'; @@ -171,7 +149,6 @@ sub ProcessFormFields { return ParseUrlString($buffer, \%::FORM, \%::MFORM); } - sub ProcessMultipartFormFields { my ($boundary) = @_; @@ -233,12 +210,10 @@ sub ProcessMultipartFormFields { } } - # check and see if a given field exists, is non-empty, and is set to a # legal value. assume a browser bug and abort appropriately if not. # if $legalsRef is not passed, just check to make sure the value exists and # is non-NULL -# sub CheckFormField (\%$;\@) { my ($formRef, # a reference to the form to check (a hash) $fieldname, # the fieldname to check @@ -265,7 +240,6 @@ sub CheckFormField (\%$;\@) { } # check and see if a given field is defined, and abort if not -# sub CheckFormFieldDefined (\%$) { my ($formRef, # a reference to the form to check (a hash) $fieldname, # the fieldname to check @@ -326,7 +300,6 @@ sub ValidateBugID { } - sub ValidateComment { # Make sure a comment is not too large (greater than 64K). @@ -338,26 +311,6 @@ sub ValidateComment { } } - -# check and see if a given string actually represents a positive -# integer, and abort if not. -# -sub CheckPosInt($) { - my ($number) = @_; # the fieldname to check - - if ( $number !~ /^[1-9][0-9]*$/ ) { - print "Received string \"$number\" when positive integer expected; "; - print Param("browserbugmessage"); - PutFooter(); - exit 0; - } -} - -sub FormData { - my ($field) = (@_); - return $::FORM{$field}; -} - sub html_quote { my ($var) = (@_); $var =~ s/\&/\&/g; @@ -383,34 +336,10 @@ sub value_quote { return $var; } -sub navigation_header { - if (defined $::COOKIE{"BUGLIST"} && $::COOKIE{"BUGLIST"} ne "" && - defined $::FORM{'id'}) { - my @bugs = split(/:/, $::COOKIE{"BUGLIST"}); - my $cur = lsearch(\@bugs, $::FORM{"id"}); - print "Bug List: (@{[$cur + 1]} of @{[$#bugs + 1]})\n"; - print "First\n"; - print "Last\n"; - if ($cur > 0) { - print "Prev\n"; - } else { - print "Prev\n"; - } - if ($cur < $#bugs) { - $::next_bug = $bugs[$cur + 1]; - print "Next\n"; - } else { - print "Next\n"; - } - print qq{  Show list\n}; - } - print "     Query page\n"; - print "     Enter new bug\n" -} - # Adds elements for bug lists. These can be inserted into the header by # (ab)using the "jscript" parameter to PutHeader, which inserts an arbitrary -# string into the header. This function is modelled on the one above. +# string into the header. This is currently used only in +# template/en/default/bug/edit.html.tmpl. sub navigation_links($) { my ($buglist) = @_; @@ -450,145 +379,9 @@ sub navigation_links($) { return $retval; } -sub make_checkboxes { - my ($src,$default,$isregexp,$name) = (@_); - my $last = ""; - my $capitalized = ""; - my $popup = ""; - my $found = 0; - $default = "" if !defined $default; - - if ($src) { - foreach my $item (@$src) { - if ($item eq "-blank-" || $item ne $last) { - if ($item eq "-blank-") { - $item = ""; - } - $last = $item; - $capitalized = $item; - $capitalized =~ tr/A-Z/a-z/; - $capitalized =~ s/^(.?)(.*)/\u$1$2/; - if ($isregexp ? $item =~ $default : $default eq $item) { - $popup .= "$capitalized
"; - $found = 1; - } else { - $popup .= "$capitalized
"; - } - } - } - } - if (!$found && $default ne "") { - $popup .= "$default"; - } - return $popup; -} - -# -# make_selection_widget: creates an HTML selection widget from a list of text strings. -# $groupname is the name of the setting (form value) that this widget will control -# $src is the list of options -# you can specify a $default value which is either a string or a regex pattern to match to -# identify the default value -# $capitalize lets you optionally capitalize the option strings; the default is the value -# of Param("capitalizelists") -# $multiple is 1 if several options are selectable (default), 0 otherwise. -# $size is used for lists to control how many items are shown. The default is 7. A list of -# size 1 becomes a popup menu. -# $preferLists is 1 if selection lists should be used in favor of radio buttons and -# checkboxes, and 0 otherwise. The default is the value of Param("preferlists"). -# -# The actual widget generated depends on the parameter settings: -# -# MULTIPLE PREFERLISTS SIZE RESULT -# 0 (single) 0 =1 Popup Menu (normal for list of size 1) -# 0 (single) 0 >1 Radio buttons -# 0 (single) 1 =1 Popup Menu (normal for list of size 1) -# 0 (single) 1 n>1 List of size n, single selection -# 1 (multi) 0 n/a Check boxes; size ignored -# 1 (multi) 1 n/a List of size n, multiple selection, of size n -# -sub make_selection_widget { - my ($groupname,$src,$default,$isregexp,$multiple, $size, $capitalize, $preferLists) = (@_); - my $last = ""; - my $popup = ""; - my $found = 0; - my $displaytext = ""; - $groupname = "" if !defined $groupname; - $default = "" if !defined $default; - $capitalize = Param("capitalizelists") if !defined $capitalize; - $multiple = 1 if !defined $multiple; - $preferLists = Param("preferlists") if !defined $preferLists; - $size = 7 if !defined $size; - my $type = "LIST"; - if (!$preferLists) { - if ($multiple) { - $type = "CHECKBOX"; - } else { - if ($size > 1) { - $type = "RADIO"; - } - } - } - - if ($type eq "LIST") { - $popup .= "$displaytext
"; - } else { - $popup .= "