version 4.8, 2019/11/09 09:41:07 |
version 4.15, 2019/11/11 12:55:38 |
|
|
$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::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 |
Line 102 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; }; |
|
|
|
# ----------------------------------------------------------------------------- |
# ----------------------------------------------------------------------------- |
|
|
# All global initialization that can be done in compile time should go to |
# All global initialization that can be done in compile time should go to |
Line 317 $maycompress = ( |
|
Line 315 $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 358 if (defined($ENV{QUERY_STRING})) { |
|
Line 356 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 757 if ($input{tarball}) { |
|
Line 763 if ($input{tarball}) { |
|
} |
} |
|
|
# Clean up. |
# Clean up. |
|
chdir(".."); |
rmtree($tmpexportdir); |
rmtree($tmpexportdir); |
|
|
&fatal(@fatal) if @fatal; |
&fatal(@fatal) if @fatal; |
|
|
<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); |
} |
} |
|
|
} |
} |
} elsif ($state eq "PreChange") { # state eq "PreChange" |
} elsif ($state eq "PreChange") { # state eq "PreChange" |
# we got removes with subsequent adds |
# we got removes with subsequent adds |
if (HAS_EDIFF) { |
|
# construct the suffix tree |
|
my $left_diff = join("\n", @$leftColRef[0..$leftRow-1]); |
|
my $right_diff = join("\n", @$rightColRef[0..$rightRow-1]); |
|
my $diff_str = String::Ediff::ediff($left_diff, $right_diff); |
|
|
|
my @diff_str = split(/ /, $diff_str); |
|
my $INFINITY = 10000000; |
|
push(@diff_str, ($INFINITY) x 8); |
|
my ($idx, $b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2) = |
|
(0, @diff_str[0..7]); |
|
my ($l_cul, $r_cul) = (0, 0); |
|
my ($ldx, $rdx) = (0, 0); |
|
my (@left_html, @right_html); |
|
for (my $j = 0; $j < $leftRow; $j++) { |
|
my $line_len = length(@$leftColRef[$j]); |
|
my $line = @$leftColRef[$j]; |
|
$l_cul += length($line) + 1; # includes "\n" |
|
my $l_culx = $l_cul - 1; # not includes "\n" |
|
if ($j < $lb1) { |
|
$line = spacedHtmlText($line); |
|
push(@left_html, "<td class=\"diff diff-changed\">$line</td>"); |
|
} elsif ($lb1 == $j) { |
|
my $html_line; |
|
while ($lb1 == $j) { |
|
my $begin_char = $l_culx - $b1; |
|
|
|
$line =~ /^(.*)(.{$begin_char})$/; |
|
$html_line .= spacedHtmlText($1) . |
|
'</span><span class="diff diff-unchanged">'; |
|
$line = $2; |
|
last if ($j != $le1); |
|
|
|
my $end_char = $l_culx - $e1; |
|
$line =~ /^(.*)(.{$end_char})$/; |
|
$html_line .= spacedHtmlText($1) . |
|
'</span><span class="diff diff-changed">'; |
|
$line = $2; |
|
|
|
$idx++; |
|
my ($tb1, $te1, $tlb1, $tle1, $tb2, $te2, $tlb2, $tle2) = |
|
($b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2); |
|
($b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2) = |
|
@diff_str[$idx*8..($idx+1)*8-1]; |
|
$lb1 = $INFINITY if ($lb1 < 0); |
|
$lb2 = $INFINITY if ($lb2 < 0); |
|
$le1 = $INFINITY if ($le1 < 0); |
|
$le2 = $INFINITY if ($le2 < 0); |
|
if ($te1 > $b1) { |
|
($b1, $lb1) = ($te1, $tle1); |
|
} |
|
if ($te2 > $b2) { |
|
($b2, $lb2) = ($te2, $tle2); |
|
} |
|
} |
|
push(@left_html, |
|
sprintf('<td><span class="diff diff-changed">%s%s</span></td>', |
|
$html_line, spacedHtmlText($line))); |
|
} elsif ($le1 == $j) { |
|
my $html_line; |
|
while ($le1 == $j) { |
|
my $end_char = $l_culx - $e1; |
|
$line =~ /^(.*)(.{$end_char})$/; |
|
$html_line .= spacedHtmlText($1) . |
|
'</span><span class="diff diff-changed">'; |
|
$line = $2; |
|
|
|
$idx++; |
|
my ($tb1, $te1, $tlb1, $tle1, $tb2, $te2, $tlb2, $tle2) = |
|
($b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2); |
|
($b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2) = |
|
@diff_str[$idx*8..($idx+1)*8-1]; |
|
$lb1 = $INFINITY if ($lb1 < 0); |
|
$lb2 = $INFINITY if ($lb2 < 0); |
|
$le1 = $INFINITY if ($le1 < 0); |
|
$le2 = $INFINITY if ($le2 < 0); |
|
if ($te1 > $b1) { |
|
($b1, $lb1) = ($te1, $tle1); |
|
} |
|
if ($te2 > $b2) { |
|
($b2, $lb2) = ($te2, $tle2); |
|
} |
|
|
|
last if ($lb1 != $j); |
|
|
|
my $begin_char = $l_culx - $b1; |
|
|
|
$line =~ /^(.*)(.{$begin_char})$/; |
|
$html_line .= spacedHtmlText($1) . |
|
'</span><span class="diff diff-unchanged">'; |
|
$line = $2; |
|
} |
|
push(@left_html, |
|
sprintf('<td><span class="diff diff-unchanged">%s%s</span></td>', |
|
$html_line, spacedHtmlText($line))); |
|
} else { |
|
$line = spacedHtmlText($line); |
|
push(@left_html, "<td class=\"diff diff-unchanged\">$line</td>"); |
|
} |
|
} |
|
($idx, $b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2) = |
|
(0, @diff_str[0..7]); |
|
$lb1 = $INFINITY if ($lb1 < 0); |
|
$lb2 = $INFINITY if ($lb2 < 0); |
|
$le1 = $INFINITY if ($le1 < 0); |
|
$le2 = $INFINITY if ($le2 < 0); |
|
for (my $j = 0; $j < $rightRow; $j++) { |
|
my $line_len = length(@$rightColRef[$j]); |
|
my $line = @$rightColRef[$j]; |
|
$r_cul += length($line) + 1; # includes "\n" |
|
my $r_culx = $r_cul - 1; # not includes "\n" |
|
if ($j < $lb2) { |
|
$line = spacedHtmlText($line); |
|
push(@right_html, "<td class=\"diff diff-changed\">$line</td>"); |
|
} elsif ($lb2 == $j) { |
|
my $html_line; |
|
while ($lb2 == $j) { |
|
my $begin_char = $r_culx - $b2; |
|
|
|
$line =~ /^(.*)(.{$begin_char})$/; |
|
$html_line .= spacedHtmlText($1) . |
|
'</span><span class="diff diff-unchanged">'; |
|
$line = $2; |
|
|
|
last if ($j != $le2); |
|
|
|
my $end_char = $r_culx - $e2; |
|
$line =~ /^(.*)(.{$end_char})$/; |
|
$html_line .= spacedHtmlText($1) . |
|
'</span><span class="diff diff-changed">'; |
|
$line = $2; |
|
|
|
$idx++; |
|
my ($tb1, $te1, $tlb1, $tle1, $tb2, $te2, $tlb2, $tle2) = |
|
($b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2); |
|
($b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2) = |
|
@diff_str[$idx*8..($idx+1)*8-1]; |
|
$lb1 = $INFINITY if ($lb1 < 0); |
|
$lb2 = $INFINITY if ($lb2 < 0); |
|
$le1 = $INFINITY if ($le1 < 0); |
|
$le2 = $INFINITY if ($le2 < 0); |
|
if ($te1 > $b1) { |
|
($b1, $lb1) = ($te1, $tle1); |
|
} |
|
if ($te2 > $b2) { |
|
($b2, $lb2) = ($te2, $tle2); |
|
} |
|
} |
|
push(@right_html, |
|
sprintf('<td><span class="diff diff-changed">%s%s</span></td>', |
|
$html_line, spacedHtmlText($line))); |
|
} elsif ($le2 == $j) { |
|
my $html_line; |
|
while ($le2 == $j) { |
|
my $end_char = $r_culx - $e2; |
|
$line =~ /^(.*)(.{$end_char})$/; |
|
$html_line .= spacedHtmlText($1) . |
|
'</span><span class="diff diff-changed">'; |
|
$line = $2; |
|
|
|
$idx++; |
|
my ($tb1, $te1, $tlb1, $tle1, $tb2, $te2, $tlb2, $tle2) = |
|
($b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2); |
|
($b1, $e1, $lb1, $le1, $b2, $e2, $lb2, $le2) = |
|
@diff_str[$idx*8..($idx+1)*8-1]; |
|
$lb1 = $INFINITY if ($lb1 < 0); |
|
$lb2 = $INFINITY if ($lb2 < 0); |
|
$le1 = $INFINITY if ($le1 < 0); |
|
$le2 = $INFINITY if ($le2 < 0); |
|
if ($te1 > $b1) { |
|
($b1, $lb1) = ($te1, $tle1); |
|
} |
|
if ($te2 > $b2) { |
|
($b2, $lb2) = ($te2, $tle2); |
|
} |
|
|
|
last if ($lb2 != $j); |
|
|
|
my $begin_char = $r_culx - $b2; |
|
$line =~ /^(.*)(.{$begin_char})$/; |
|
$html_line .= spacedHtmlText($1) . |
|
'</span><span class="diff diff-unchanged">'; |
|
$line = $2; |
|
} |
|
push(@right_html, |
|
sprintf('<td nowrap="nowrap"><span class="diff diff-unchanged"'. |
|
'>%s%s</span></td>', |
|
$html_line, spacedHtmlText($line))); |
|
} else { |
|
$line = spacedHtmlText ($line); |
|
push @right_html, "<td class=\"diff diff-unchanged\">$line</td>"; |
|
} |
|
} |
|
for (my $j = 0; $j < $leftRow || $j < $rightRow ; $j++) { # dump out both cols |
|
print '<tr>'; |
|
if ($j < $leftRow) { |
|
print $left_html[$j]; |
|
} else { |
|
print '<td class="diff diff-changed-missing"> </td>'; |
|
} |
|
if ($j < $rightRow) { |
|
print $right_html[$j]; |
|
} else { |
|
print '<td class="diff diff-changed-missing"> </td>'; |
|
} |
|
print "</tr>\n"; |
|
} |
|
} else { |
|
for (my $j = 0; $j < $leftRow || $j < $rightRow; $j++) { # dump both cols |
for (my $j = 0; $j < $leftRow || $j < $rightRow; $j++) { # dump both cols |
print "<tr>\n"; |
print "<tr>\n"; |
if ($j < $leftRow) { |
if ($j < $leftRow) { |
|
|
} |
} |
print "\n</tr>\n"; |
print "\n</tr>\n"; |
} |
} |
} |
|
} |
} |
} |
} |
|
|
Line 4234 sub http_header(;$$) |
|
Line 4032 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 4247 sub http_header(;$$) |
|
Line 4043 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"; |
} |
} |
|
|
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; |