diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2738643950d6f2c0aa15875014c7364b2ee0286d..95988fba4ab743e26b246aa2c22c6e36ef50efaf 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2758,6 +2758,15 @@ sub get_file_owner {
return to_utf8($owner);
}
+# assume that file exists
+sub insert_file {
+ my $filename = shift;
+
+ open my $fd, '<', $filename;
+ print map(to_utf8, <$fd>);
+ close $fd;
+}
+
## ......................................................................
## mimetype related functions
@@ -2946,9 +2955,7 @@ sub git_header_html {
"
\n";
if (-f $site_header) {
- open (my $fd, $site_header);
- print <$fd>;
- close $fd;
+ insert_file($site_header);
}
print "\n"; # class="page_footer"
if (-f $site_footer) {
- open (my $fd, $site_footer);
- print <$fd>;
- close $fd;
+ insert_file($site_footer);
}
print "\n" .
@@ -4376,9 +4381,7 @@ sub git_project_list {
git_header_html();
if (-f $home_text) {
print "\n";
- open (my $fd, $home_text);
- print <$fd>;
- close $fd;
+ insert_file($home_text);
print "
\n";
}
print $cgi->startform(-method => "get") .
@@ -4490,13 +4493,10 @@ sub git_summary {
print "\n";
if (-s "$projectroot/$project/README.html") {
- if (open my $fd, "$projectroot/$project/README.html") {
- print "readme
\n" .
- "\n";
- print $_ while (<$fd>);
- print "\n
\n"; # class="readme"
- close $fd;
- }
+ print "readme
\n" .
+ "\n";
+ insert_file("$projectroot/$project/README.html");
+ print "\n
\n"; # class="readme"
}
# we need to request one more than 16 (0..15) to check if