From: Junio C Hamano Date: Wed, 26 Oct 2011 23:16:31 +0000 (-0700) Subject: Merge branch 'lh/gitweb-site-html-head' X-Git-Tag: v1.7.8-rc0~10 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/208a1cc3d37f7c0f770440095fd3fa621f3ce006?ds=inline;hp=-c Merge branch 'lh/gitweb-site-html-head' * lh/gitweb-site-html-head: gitweb: provide a way to customize html headers --- 208a1cc3d37f7c0f770440095fd3fa621f3ce006 diff --combined gitweb/gitweb.perl index a95226e089,d33510804b..4f0c3bd90c --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@@ -85,6 -85,8 +85,8 @@@ our $home_link_str = "++GITWEB_HOME_LIN our $site_name = "++GITWEB_SITENAME++" || ($ENV{'SERVER_NAME'} || "Untitled") . " Git"; + # html snippet to include in the section of each page + our $site_html_head_string = "++GITWEB_SITE_HTML_HEAD_STRING++"; # filename of html text to include at top of each page our $site_header = "++GITWEB_SITE_HEADER++"; # html text to include at home page @@@ -1517,17 -1519,6 +1519,17 @@@ sub esc_path return $str; } +# Sanitize for use in XHTML + application/xml+xhtm (valid XML 1.0) +sub sanitize { + my $str = shift; + + return undef unless defined $str; + + $str = to_utf8($str); + $str =~ s|([[:cntrl:]])|($1 =~ /[\t\n\r]/ ? $1 : quot_cec($1))|eg; + return $str; +} + # Make control characters "printable", using character escape codes (CEC) sub quot_cec { my $cntrl = shift; @@@ -2886,7 -2877,7 +2888,7 @@@ sub filter_forks_from_projects_list $path =~ s/\.git$//; # forks of 'repo.git' are in 'repo/' directory next if ($path =~ m!/$!); # skip non-bare repositories, e.g. 'repo/.git' next unless ($path); # skip '.git' repository: tests, git-instaweb - next unless (-d $path); # containing directory exists + next unless (-d "$projectroot/$path"); # containing directory exists $pr->{'forks'} = []; # there can be 0 or more forks of project # add to trie @@@ -3879,6 -3870,11 +3881,11 @@@ EO print "\n"; } print_header_links($status); + + if (defined $site_html_head_string) { + print to_utf8($site_html_head_string); + } + print "\n" . "\n"; @@@ -6495,8 -6491,7 +6502,8 @@@ sub git_blob $nr++; $line = untabify($line); printf qq!
%4i %s
\n!, - $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1); + $nr, esc_attr(href(-replay => 1)), $nr, $nr, + $syntax ? sanitize($line) : esc_html($line, -nbsp=>1); } } close $fd