[BACK]Return to cvsweb.cgi CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / cvsweb

Diff for /cvsweb/cvsweb.cgi between version 4.1 and 4.14

version 4.1, 2019/11/08 21:08:26 version 4.14, 2019/11/11 12:46:23
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl
 # $Id$  # $Id$
 # $knu: cvsweb.cgi,v 1.299 2010/11/13 16:37:18 simon  # $knu: cvsweb.cgi,v 1.299 2010/11/13 16:37:18 simon
 #  #
Line 50 
Line 50 
 require 5.006;  require 5.006;
   
 use strict;  use strict;
   
 use warnings;  use warnings;
 use filetest qw(access);  use filetest qw(access);
   
Line 65  use vars qw (
Line 64  use vars qw (
   @revisions %state %difflines %log %branchpoint @revorder $keywordsubstitution    @revisions %state %difflines %log %branchpoint @revorder $keywordsubstitution
   $prcgi @prcategories $re_prcategories $prkeyword $re_prkeyword $mancgi    $prcgi @prcategories $re_prcategories $prkeyword $re_prkeyword $mancgi
   $doCheckout $scriptname $scriptwhere    $doCheckout $scriptname $scriptwhere
   $where $Browser $nofilelinks $maycompress @stickyvars %funcline_regexp    $where $Browser $nofilelinks $maycompress @stickyvars
   $is_links $is_lynx $is_w3m $is_msie $is_mozilla3 $is_textbased    $is_links $is_lynx $is_w3m $is_msie $is_mozilla3 $is_textbased
   %input $query $barequery $sortby $bydate $byrev $byauthor    %input $query $barequery $sortby $bydate $byrev $byauthor
   $bylog $byfile $defaultDiffType $logsort $cvstree $cvsroot    $bylog $byfile $defaultDiffType $logsort $cvstree $cvsroot
Line 87  use vars qw (
Line 86  use vars qw (
   $allow_enscript @enscript_options %enscript_types    $allow_enscript @enscript_options %enscript_types
 );  );
   
   require Compress::Zlib;
 use Cwd                   qw(abs_path);  use Cwd                   qw(abs_path);
 use File::Basename        qw(dirname);  
 use File::Path            qw(rmtree);  use File::Path            qw(rmtree);
 use File::Spec::Functions qw(canonpath catdir catfile curdir devnull rootdir  use File::Spec::Functions qw(canonpath catdir catfile curdir devnull rootdir
                              tmpdir updir);                               tmpdir updir);
Line 104  use constant CVSWEBMARKUP => qr{^text/(x-cvsweb|vnd\.v
Line 103  use constant CVSWEBMARKUP => qr{^text/(x-cvsweb|vnd\.v
 use constant LOG_FILESEPR => qr/^={77}$/o;  use constant LOG_FILESEPR => qr/^={77}$/o;
 use constant LOG_REVSEPR  => qr/^-{28}$/o;  use constant LOG_REVSEPR  => qr/^-{28}$/o;
   
 use constant HAS_ZLIB     => eval { require Compress::Zlib; };  
 use constant HAS_EDIFF    => eval { require String::Ediff;  };  use constant HAS_EDIFF    => eval { require String::Ediff;  };
   
 # -----------------------------------------------------------------------------  # -----------------------------------------------------------------------------
Line 115  use constant HAS_EDIFF    => eval { require String::Ed
Line 113  use constant HAS_EDIFF    => eval { require String::Ed
   
 BEGIN  BEGIN
 {  {
   $VERSION = '3.0.6';    $VERSION = '3.1';
   
   $HTML_DOCTYPE =    $HTML_DOCTYPE =
     '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' .      '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' .
Line 204  sub checkout_to_temp($$$);
Line 202  sub checkout_to_temp($$$);
 # (think mod_perl)...  # (think mod_perl)...
 delete(@ENV{qw(PATH IFS CDPATH ENV BASH_ENV)});  delete(@ENV{qw(PATH IFS CDPATH ENV BASH_ENV)});
   
 my ($mydir) = (dirname($0) =~ /(.*)/);    # untaint  # Location of the configuration file inside the web server chroot:
   $config = '/conf/cvsweb/cvsweb.conf';
   
 ##### Start of Configuration Area ########  
   
 # == EDIT this ==  
 # Locations to search for user configuration, in order:  
 for (catfile($mydir, 'cvsweb.conf'), '/usr/local/etc/cvsweb/cvsweb.conf') {  
   if (-r $_) {  
     $config = $_;  
     last;  
   }  
 }  
   
 ##### End of Configuration Area   ########  
   
 undef $mydir;  
   
 ######## Configuration parameters #########  ######## Configuration parameters #########
   
 @CVSrepositories = @CVSROOT = %CVSROOT = %MIRRORS = %DEFAULTVALUE = %ICONS =  @CVSrepositories = @CVSROOT = %CVSROOT = %MIRRORS = %DEFAULTVALUE = %ICONS =
Line 237  $cvstreedefault = $logo = $defaulttitle =
Line 221  $cvstreedefault = $logo = $defaulttitle =
   
 $allow_version_select = $allow_mailtos = $allow_log_extra = 1;  $allow_version_select = $allow_mailtos = $allow_log_extra = 1;
   
 @DIFFTYPES = qw(h H u c s);  @DIFFTYPES = qw(h H u c);
 @DIFFTYPES{@DIFFTYPES} = (  @DIFFTYPES{@DIFFTYPES} = (
   {    {
     'descr'   => 'colored',      'descr'   => 'colored',
Line 259  $allow_version_select = $allow_mailtos = $allow_log_ex
Line 243  $allow_version_select = $allow_mailtos = $allow_log_ex
     'opts'    => ['-c'],      'opts'    => ['-c'],
     'colored' => 0,      'colored' => 0,
   },    },
   {  
     'descr'   => 'side by side',  
     # width=168 should be enough to support 80 character line lengths  
     'opts'    => ['--side-by-side', '--width=168'],  
     'colored' => 0,  
   },  
 );  );
   
 @LOGSORTKEYS = qw(cvs date rev);  @LOGSORTKEYS = qw(cvs date rev);
Line 339  $maycompress = (
Line 317  $maycompress = (
     && $ENV{HTTP_ACCEPT_ENCODING} =~ /gzip/)      && $ENV{HTTP_ACCEPT_ENCODING} =~ /gzip/)
    || $is_mozilla3)     || $is_mozilla3)
   && !$is_msie    && !$is_msie
   && !(defined($ENV{MOD_PERL}) && !HAS_ZLIB)    && !(defined($ENV{MOD_PERL}))
 );  );
   
 # Parameters that will be sticky in all constructed links/query strings.  # Parameters that will be sticky in all constructed links/query strings.
Line 380  if (defined($ENV{QUERY_STRING})) {
Line 358  if (defined($ENV{QUERY_STRING})) {
     $p =~ y/+/ /;      $p =~ y/+/ /;
     my ($key, $val) = split(/=/, $p, 2);      my ($key, $val) = split(/=/, $p, 2);
     next unless defined($key);      next unless defined($key);
     $val = 1 unless defined($val);      $key = uri_unescape($key);
     ($key = uri_unescape($key)) =~ /[[:graph:]]/ or next;      $key =~ /([^a-z_12-])/ and fatal('404 Not Found',
     ($val = uri_unescape($val)) =~ /[[:graph:]]/ or next;        'Invalid character "%s" in query parameter "%s"', $1, $key);
       if (defined $val) {
         $val = uri_unescape($val);
         $val =~ /([^a-zA-Z_01-9.\/-])/ and fatal('404 Not Found',
           'Invalid character "%s" in the value "%s" of the query parameter "%s"',
           $1, $val, $key);
       } else {
         $val = 1;
       }
     $query{$key} = $val;      $query{$key} = $val;
   }    }
 }  }
Line 555  foreach (@stickyvars) {
Line 541  foreach (@stickyvars) {
 }  }
   
 if ($allow_enscript) {  if ($allow_enscript) {
   push(@DIFFTYPES, qw(uc cc sc));    push(@DIFFTYPES, qw(uc cc));
   @DIFFTYPES{qw(uc cc sc)} = (    @DIFFTYPES{qw(uc cc)} = (
     {      {
      'descr'   => 'unified, colored',       'descr'   => 'unified, colored',
      'opts'    => ['-u'],       'opts'    => ['-u'],
Line 567  if ($allow_enscript) {
Line 553  if ($allow_enscript) {
      'opts'    => ['-c'],       'opts'    => ['-c'],
      'colored' => 0,       'colored' => 0,
     },      },
     {  
      'descr'   => 'side by side, colored',  
      # width=168 should be enough to support 80 character line lengths  
      'opts'    => ['--side-by-side', '--width=168'],  
      'colored' => 0,  
     },  
   );    );
 } else {  } else {
   # No Enscript -> respect difftype, but don't offer colorization.    # No Enscript -> respect difftype, but don't offer colorization.
Line 785  if ($input{tarball}) {
Line 765  if ($input{tarball}) {
   }    }
   
   # Clean up.    # Clean up.
     chdir("..");
   rmtree($tmpexportdir);    rmtree($tmpexportdir);
   
   &fatal(@fatal) if @fatal;    &fatal(@fatal) if @fatal;
Line 1198  EOF
Line 1179  EOF
 <legend>General options</legend>  <legend>General options</legend>
 <input type="hidden" name="copt" value="1" />  <input type="hidden" name="copt" value="1" />
 EOF  EOF
     for my $v qw(hidecvsroot hidenonreadable) {      for my $v (qw(hidecvsroot hidenonreadable)) {
       printf(qq{<input type="hidden" name="%s" value="%s" />\n},        printf(qq{<input type="hidden" name="%s" value="%s" />\n},
              $v, $input{$v} || 0);               $v, $input{$v} || 0);
     }      }
Line 1568  sub htmlify($;$)
Line 1549  sub htmlify($;$)
          }{           }{
             my($text, $name, $section) = ($1, $2, defined($3) ? $3 : $4);              my($text, $name, $section) = ($1, $2, defined($3) ? $3 : $4);
             ($name =~ /[A-Za-z]/ && $name !~ /\.(:|$)/)              ($name =~ /[A-Za-z]/ && $name !~ /\.(:|$)/)
              ? &link($text, sprintf($mancgi, $section, uri_escape($name)))               ? &link($text, sprintf($mancgi, uri_escape($name), $section))
               : $text;                : $text;
          }egx;           }egx;
       } $_;        } $_;
Line 2319  sub doDiff($$$$$$)
Line 2300  sub doDiff($$$$$$)
   my @difftype       = @{$difftype->{opts}};    my @difftype       = @{$difftype->{opts}};
   my $human_readable = $difftype->{colored};    my $human_readable = $difftype->{colored};
   
   # Apply special diff options.  -p and -F are not available with side by side    # Apply special diff options.
   # diffs and may cause problems with older (< 2.8) versions of diffutils if    push @difftype, '-p' if $showfunc;
   # used with --side-by-side.  
   if ($showfunc && $f !~ /^s/) {  
     push(@difftype, '-p');  
     while (my ($re1, $re2) = each %funcline_regexp) {  
       if ($fullname =~ $re1) {  
         push(@difftype, '-F', $re2);  
         last;  
       }  
     }  
   }  
   
   if ($human_readable) {    if ($human_readable) {
     push(@difftype, '-w')  if $hr_ignwhite;      push(@difftype, '-w')  if $hr_ignwhite;
Line 2956  sub printLog($$$;$$)
Line 2927  sub printLog($$$;$$)
   print "<br />\n";    print "<br />\n";
   
   print '<i>';    print '<i>';
   if (defined @mytz) {    if (@mytz) {
     my ($est) = $mytz[(localtime($date{$_}))[8]];      my ($est) = $mytz[(localtime($date{$_}))[8]];
     print scalar localtime($date{$_}), " $est</i> (";      print scalar localtime($date{$_}), " $est</i> (";
   } else {    } else {
Line 4232  sub htmlquote($)
Line 4203  sub htmlquote($)
   # Special Characters; RFC 1866    # Special Characters; RFC 1866
   s/&/&amp;/g;    s/&/&amp;/g;
   s/\"/&quot;/g;    s/\"/&quot;/g;
     s/"/&quot;/g;
   s/</&lt;/g;    s/</&lt;/g;
   s/>/&gt;/g;    s/>/&gt;/g;
   return $_;    return $_;
Line 4271  sub http_header(;$$)
Line 4243  sub http_header(;$$)
   push(@headers, 'Last-Modified: ' . scalar gmtime($moddate) . ' GMT')    push(@headers, 'Last-Modified: ' . scalar gmtime($moddate) . ' GMT')
     if $moddate;      if $moddate;
   push(@headers, 'Content-Type: ' . $content_type);    push(@headers, 'Content-Type: ' . $content_type);
     push(@headers, "Content-Security-Policy: default-src 'none'; " .
       "img-src 'self'; style-src 'unsafe-inline'");
   
   if ($allow_compress && $maycompress) {    if ($allow_compress && $maycompress) {
     if (HAS_ZLIB  
         || (defined($CMD{gzip}) && open(GZIP, "| $CMD{gzip} -1 -c")))  
     {  
   
       push(@headers, 'Content-Encoding: gzip');        push(@headers, 'Content-Encoding: gzip');
       push(@headers, 'Vary: Accept-Encoding');     # RFC 2616, 14.44        push(@headers, 'Vary: Accept-Encoding');     # RFC 2616, 14.44
       print join("\r\n", @headers) . "\r\n\r\n";        print join("\r\n", @headers) . "\r\n\r\n";
Line 4284  sub http_header(;$$)
Line 4254  sub http_header(;$$)
       $| = 1;        $| = 1;
       $| = 0;                                      # Flush header output.        $| = 0;                                      # Flush header output.
   
       tie(*GZIP, __PACKAGE__, \*STDOUT) if HAS_ZLIB;        tie(*GZIP, __PACKAGE__, \*STDOUT);
       select(GZIP);        select(GZIP);
       $gzip_open = 1;        $gzip_open = 1;
   
     } else {  
   
       print join("\r\n", @headers) . "\r\n\r\n";  
       printf  
         '<span style="font-size: smaller">Unable to find gzip binary in the <b>$command_path</b> (<code>%s</code>) to compress output</span><br />',  
           htmlquote(join(':', @command_path));  
     }  
   
   } else {    } else {
     print join("\r\n", @headers) . "\r\n\r\n";      print join("\r\n", @headers) . "\r\n\r\n";
   }    }
Line 4463  sub TIEHANDLE
Line 4424  sub TIEHANDLE
               crc    => 0,                crc    => 0,
               len    => 0,                len    => 0,
             };              };
   my ($header) = pack("c10",    my ($header) = pack("C10",
                       MAGIC1, MAGIC2, Compress::Zlib::Z_DEFLATED(),                        MAGIC1, MAGIC2, Compress::Zlib::Z_DEFLATED(),
                       0, 0, 0, 0, 0, 0, OSCODE);                        0, 0, 0, 0, 0, 0, OSCODE);
   print {$o->{handle}} $header;    print {$o->{handle}} $header;

Legend:
Removed from v.4.1  
changed lines
  Added in v.4.14

CVSweb