X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=blobdiff_plain;f=lib%2FPackages%2FCGI.pm;h=beb4e255e9844bc68b4a32006db528e1354e9bd6;hp=34d7a5f341636414d0175e089561fd241c9c5823;hb=08aa87adaf6c59131d01f8a4a078dc4e78475788;hpb=e0996d1bc5a737ae3fbeb9d1598d106ad5496a6a diff --git a/lib/Packages/CGI.pm b/lib/Packages/CGI.pm index 34d7a5f..beb4e25 100644 --- a/lib/Packages/CGI.pm +++ b/lib/Packages/CGI.pm @@ -4,7 +4,6 @@ use strict; use warnings; use Exporter; -use Packages::Config; our @ISA = qw( Exporter ); our @EXPORT = qw( DEBUG debug fatal_error get_mime ); @@ -20,20 +19,24 @@ my %mime_types = ( 'txt.gz' => 'text/plain', html => 'text/html', rss => 'application/rss+xml', + rfc822 => 'text/plain', ); sub get_mime { return $mime_types{$_[0]} || $_[1] || 'text/html'; } -our (@fatal_errors, @errors, @debug, @msgs, @hints, @notes); +our (@fatal_errors, @errors, @debug, @hints); +our $http_code; sub reset { - @fatal_errors = @errors = @debug = @msgs = @hints = @notes = (); + @fatal_errors = @errors = @debug = @hints = (); + $http_code = 200; } sub fatal_error { push @fatal_errors, $_[0]; + $http_code = $_[1] if $_[1]; } sub error { push @errors, $_[0]; @@ -45,27 +48,17 @@ sub debug { my $lvl = $_[1] || 0; push(@debug, $_[0]) if $debug > $lvl; } -sub msg { - push @msgs, $_[0]; -} -sub note { - push @notes, [ @_ ]; -} sub get_errors { (@fatal_errors, @errors) } sub get_debug { return unless $debug && @debug; return @debug; } -sub get_msgs { @msgs }; sub get_hints { @hints }; -sub get_notes { @notes }; sub get_all_messages { return { errors => [ @fatal_errors, @errors ], debugs => $debug ? \@debug : [], - msgs => \@msgs, hints => \@hints, - notes => \@notes, }; } @@ -95,7 +88,7 @@ sub parse_params { foreach my $param ( keys %params ) { - debug( "Param $param", 2 ) if DEBUG; + debug( "Param $param", 2 ) if DEBUG; my $p_value_orig = $cgi->param($param); @@ -345,8 +338,8 @@ sub printindexline { sub string2id { my $string = "@_"; - - $string =~ s/[^\w]/_/g; + + $string =~ s/[^\w:.-]/_/g; return $string; }