X-Git-Url: https://git.ladys.computer/Gitweb/blobdiff_plain/405f6c6bb54bd9050d08cd00d9282a48c76a7adb84b3596aace35b5804cb6411..51260dcf21ff9885b2824f532d504eb4946ee8f5ecf5ebe3d9d00031ec79f5dd:/gitweb.cgi diff --git a/gitweb.cgi b/gitweb.cgi index 01ee4cb..c497d26 100755 --- a/gitweb.cgi +++ b/gitweb.cgi @@ -12,17 +12,19 @@ use warnings; use CGI qw(:standard :escapeHTML -nosticky); use CGI::Util qw(unescape); use CGI::Carp qw(fatalsToBrowser); +use Encode; use Fcntl ':mode'; +binmode STDOUT, ':utf8'; my $cgi = new CGI; -my $version = "248"; +my $version = "256"; my $my_url = $cgi->url(); my $my_uri = $cgi->url(-absolute => 1); -my $rss_link = ""; +my $rss_link = ""; # absolute fs-path which will be prepended to the project path #my $projectroot = "/pub/scm"; -my $projectroot = "/home/kay/public_html/pub/scm"; +my $projectroot = "/home/kay/public_html/pub/scm"; # location of the git-core binaries my $gitbin = "/usr/bin"; @@ -37,8 +39,8 @@ my $home_link = $my_uri; my $home_text = "indextext.html"; # source of projects list -#my $projects_list = $projectroot; -my $projects_list = "index/index.aux"; +#my $projects_list = $projectroot; +my $projects_list = "index/index.aux"; # input validation and dispatch my $action = $cgi->param('a'); @@ -78,8 +80,8 @@ if (defined $project) { undef $project; die_error(undef, "No such project."); } - $rss_link = ""; + $rss_link = ""; $ENV{'GIT_DIR'} = "$projectroot/$project"; } else { git_project_list(); @@ -144,7 +146,7 @@ sub validate_input { if ($input =~ m/(^|\/)(|\.|\.\.)($|\/)/) { return undef; } - if ($input =~ m/[^a-zA-Z0-9_ \.\/\-\+\#\~]/) { + if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \t\.\/\-\+\#\~\%]/) { return undef; } return $input; @@ -207,10 +209,31 @@ if (!defined $action || $action eq "summary") { exit; } -sub esc { +# quote unsafe chars, but keep the slash, even when it's not +# correct, but quoted slashes look too horrible in bookmarks +sub esc_param { my $str = shift; - $str =~ s/ /%20/g; + $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg; $str =~ s/\+/%2B/g; + $str =~ s/ /\+/g; + return $str; +} + +# replace invalid utf8 character with SUBSTITUTION sequence +sub esc_html { + my $str = shift; + $str = decode("utf8", $str, Encode::FB_DEFAULT); + $str = escapeHTML($str); + return $str; +} + +# git may return quoted and escaped filenames +sub unquote { + my $str = shift; + if ($str =~ m/^"(.*)"$/) { + $str = $1; + $str =~ s/\\([0-7]{1,3})/chr(oct($1))/eg; + } return $str; } @@ -294,11 +317,11 @@ a.rss_logo:hover { background-color:#ee5500; } EOF print "