From e9cc64a6ade0f470d3ef5683d0193b89b630bdae Mon Sep 17 00:00:00 2001 From: Stricted Date: Sat, 11 Feb 2017 21:04:32 +0100 Subject: [PATCH] update gitweb to 2.11.0 --- index.cgi | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/index.cgi b/index.cgi index 705c6d4..0f60352 100644 --- a/index.cgi +++ b/index.cgi @@ -31,7 +31,7 @@ BEGIN { CGI->compile() if $ENV{'MOD_PERL'}; } -our $version = "2.1.4-Stricted"; +our $version = "2.11.0-stricted"; our ($my_url, $my_uri, $base_url, $path_info, $home_link); sub evaluate_uri { @@ -1620,7 +1620,7 @@ sub esc_path { return $str; } -# Sanitize for use in XHTML + application/xml+xhtm (valid XML 1.0) +# Sanitize for use in XHTML + application/xml+xhtml (valid XML 1.0) sub sanitize { my $str = shift; @@ -2040,10 +2040,24 @@ sub format_log_line_html { my $line = shift; $line = esc_html($line, -nbsp=>1); - $line =~ s{\b([0-9a-fA-F]{8,40})\b}{ + $line =~ s{ + \b + ( + # The output of "git describe", e.g. v2.10.0-297-gf6727b0 + # or hadoop-20160921-113441-20-g094fb7d + (?a({-href => href(action=>"object", hash=>$1), -class => "text"}, $1); - }eg; + }egx; return $line; } @@ -2094,7 +2108,7 @@ sub format_ref_marker { -href => href( action=>$dest_action, hash=>$dest - )}, $name); + )}, esc_html($name)); $markers .= " " . $link . ""; @@ -3917,7 +3931,7 @@ sub blob_contenttype { # guess file syntax for syntax highlighting; return undef if no highlighting # the name of syntax can (in the future) depend on syntax highlighter used sub guess_file_syntax { - my ($highlight, $mimetype, $file_name) = @_; + my ($highlight, $file_name) = @_; return undef unless ($highlight && defined $file_name); my $basename = basename($file_name, '.in'); return $highlight_basename{$basename} @@ -3935,12 +3949,16 @@ sub guess_file_syntax { # or return original FD if no highlighting sub run_highlighter { my ($fd, $highlight, $syntax) = @_; - return $fd unless ($highlight && defined $syntax); + return $fd unless ($highlight); close $fd; + my $syntax_arg = (defined $syntax) ? "--syntax $syntax" : "--force"; open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ". + quote_command($^X, '-CO', '-MEncode=decode,FB_DEFAULT', '-pse', + '$_ = decode($fe, $_, FB_DEFAULT) if !utf8::decode($_);', + '--', "-fe=$fallback_encoding")." | ". quote_command($highlight_bin). - " --replace-tabs=8 --fragment --syntax $syntax |" + " --replace-tabs=8 --fragment $syntax_arg |" or die_error(500, "Couldn't open file or run syntax highlighter"); return $fd; } @@ -4813,11 +4831,11 @@ sub git_difftree_body { my ($difftree, $hash, @parents) = @_; my ($parent) = $parents[0]; my $have_blame = gitweb_check_feature('blame'); + print "
\n"; if ($#{$difftree} > 10) { - print "
\n"; print(($#{$difftree} + 1) . " files changed:\n"); - print "
\n"; } + print "
\n"; print " 1 ? "combined " : "") . @@ -5742,6 +5760,7 @@ sub git_project_list_rows { "\n" . "\n"; } + print ''; print ""; } @@ -5885,6 +5904,7 @@ sub git_shortlog_body { print "
 ".($to + 1)." project".($to > 1 ? ($to < 1 ? "" : "s") : "")." found 
\n"; my $alternate = 1; + my $graph_rand = int(rand(99999)); my $head = git_get_head_hash($project); @@ -7095,9 +7115,8 @@ sub git_blob { $have_blame &&= ($mimetype =~ m!^text/!); my $highlight = gitweb_check_feature('highlight'); - my $syntax = guess_file_syntax($highlight, $mimetype, $file_name); - $fd = run_highlighter($fd, $highlight, $syntax) - if $syntax; + my $syntax = guess_file_syntax($highlight, $file_name); + $fd = run_highlighter($fd, $highlight, $syntax); git_header_html(undef, $expires); my $formats_nav = ''; @@ -7150,7 +7169,7 @@ sub git_blob { $line = untabify($line); printf qq!
%4i %s
\n!, $nr, esc_attr(href(-replay => 1)), $nr, $nr, - $syntax ? sanitize($line) : esc_html($line, -nbsp=>1); + $highlight ? sanitize($line) : esc_html($line, -nbsp=>1); } } close $fd @@ -7617,7 +7636,7 @@ sub git_object { git_cmd(), 'cat-file', '-t', $object_id) . ' 2> /dev/null' or die_error(404, "Object does not exist"); $type = <$fd>; - chomp $type; + defined $type && chomp $type; close $fd or die_error(404, "Object does not exist"); -- 2.20.1