From: Junio C Hamano Date: Tue, 2 Mar 2010 20:44:11 +0000 (-0800) Subject: Merge branch 'jn/gitweb-config-error-die' X-Git-Tag: v1.7.1-rc0~108 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ca97d26cc612348baa423475adfb48194386b4a5?ds=inline;hp=-c Merge branch 'jn/gitweb-config-error-die' * jn/gitweb-config-error-die: gitweb: Die if there are parsing errors in config file --- ca97d26cc612348baa423475adfb48194386b4a5 diff --combined gitweb/gitweb.perl index 3c879b88fe,20106a4f42..32b04a469e --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@@ -550,11 -550,14 +550,14 @@@ sub filter_snapshot_fmts } our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++"; + our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++"; + # die if there are errors parsing config file if (-e $GITWEB_CONFIG) { do $GITWEB_CONFIG; - } else { - our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++"; - do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; + die $@ if $@; + } elsif (-e $GITWEB_CONFIG_SYSTEM) { + do $GITWEB_CONFIG_SYSTEM; + die $@ if $@; } # Get loadavg of system, to compare against $maxload. @@@ -1143,7 -1146,6 +1146,7 @@@ sub validate_refname # in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning sub to_utf8 { my $str = shift; + return undef unless defined $str; if (utf8::valid($str)) { utf8::decode($str); return $str; @@@ -1156,7 -1158,6 +1159,7 @@@ # correct, but quoted slashes look too horrible in bookmarks sub esc_param { my $str = shift; + return undef unless defined $str; $str =~ s/([^A-Za-z0-9\-_.~()\/:@ ]+)/CGI::escape($1)/eg; $str =~ s/ /\+/g; return $str; @@@ -1165,7 -1166,6 +1168,7 @@@ # quote unsafe chars in whole URL, so some charactrs cannot be quoted sub esc_url { my $str = shift; + return undef unless defined $str; $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg; $str =~ s/\+/%2B/g; $str =~ s/ /\+/g; @@@ -1177,8 -1177,6 +1180,8 @@@ sub esc_html my $str = shift; my %opts = @_; + return undef unless defined $str; + $str = to_utf8($str); $str = $cgi->escapeHTML($str); if ($opts{'-nbsp'}) { @@@ -1193,8 -1191,6 +1196,8 @@@ sub esc_path my $str = shift; my %opts = @_; + return undef unless defined $str; + $str = to_utf8($str); $str = $cgi->escapeHTML($str); if ($opts{'-nbsp'}) { @@@ -3379,7 -3375,7 +3382,7 @@@ sub git_footer_html ""; } -# die_error(, ) +# die_error(, [, ]) # Example: die_error(404, 'Hash not found') # By convention, use the following status codes (as defined in RFC 2616): # 400: Invalid or missing CGI parameters, or @@@ -3394,7 -3390,7 +3397,7 @@@ # or down for maintenance). Generally, this is a temporary state. sub die_error { my $status = shift || 500; - my $error = shift || "Internal server error"; + my $error = esc_html(shift) || "Internal Server Error"; my $extra = shift; my %http_responses = (