* cvsweb: Delete support for external %DIFF_COMMANDS.
@ 2019-11-29 18:50 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-11-29 18:50 UTC (permalink / raw)
To: source
Log Message:
-----------
Delete support for external %DIFF_COMMANDS.
Files like spreadsheets normally aren't committed to CVS.
Besides, it is not a good idea to run random, not necessarily
trustworthy external programs in a web application context.
Modified Files:
--------------
cvsweb:
INSTALL
cvsweb.cgi
cvsweb.conf
Revision Data
-------------
Index: cvsweb.cgi
===================================================================
RCS file: /home/cvs/mandoc/cvsweb/cvsweb.cgi,v
retrieving revision 4.36
retrieving revision 4.37
diff -Lcvsweb.cgi -Lcvsweb.cgi -u -p -r4.36 -r4.37
--- cvsweb.cgi
+++ cvsweb.cgi
@@ -57,7 +57,7 @@ use vars qw (
$VERSION $CheckoutMagic $MimeTypes $DEBUG
$config $allow_version_select
@CVSrepositories @CVSROOT %CVSROOT %CVSROOTdescr %DEFAULTVALUE %MTYPES
- %DIFF_COMMANDS @DIFFTYPES %DIFFTYPES @LOGSORTKEYS %LOGSORTKEYS
+ @DIFFTYPES %DIFFTYPES @LOGSORTKEYS %LOGSORTKEYS
%alltags %fileinfo %tags @branchnames %nameprinted
%symrev %revsym @allrevisions %date %author @revdisplayorder
@revisions %state %difflines %log %branchpoint @revorder $keywordsubstitution
@@ -86,7 +86,7 @@ use Cwd qw(abs_path);
use File::Path qw(rmtree);
use File::Spec::Functions qw(canonpath catdir catfile curdir devnull rootdir
tmpdir updir);
-use File::Temp qw(tempdir tempfile);
+use File::Temp qw(tempdir);
use IPC::Run qw();
use Time::Local qw(timegm);
use URI::Escape qw(uri_escape uri_unescape);
@@ -182,7 +182,6 @@ sub link_tags($);
sub forbidden($);
sub startproc(@);
sub runproc(@);
-sub checkout_to_temp($$$);
# Get rid of unsafe environment vars. Don't do this in the BEGIN block
# (think mod_perl)...
@@ -198,7 +197,7 @@ $config = '/conf/cvsweb/cvsweb.conf';
######## Configuration parameters #########
@CVSrepositories = @CVSROOT = %CVSROOT = %DEFAULTVALUE =
- %MTYPES = %tags = %alltags = %fileinfo = %DIFF_COMMANDS = ();
+ %MTYPES = %tags = %alltags = %fileinfo = ();
$logo = $defaulttitle =
$address = $shortLogLen = $show_author =
@@ -2062,60 +2061,6 @@ sub doDiff($$$$$$)
my $mimetype = getMimeType($fullname);
- #
- # Check for per-MIME type diff commands.
- #
- my $diffcmd = undef;
- if (my $diffcmds = $DIFF_COMMANDS{lc($mimetype)}) {
- if ($f =~ /^ext(\d*)$/) {
- my $n = $1 || 0;
- $diffcmd = $diffcmds->[$n];
- }
- }
- if ($diffcmd && $diffcmd->{cmd} && $diffcmd->{name}) {
-
- if ($diffcmd->{args} && ref($diffcmd->{args}) ne 'ARRAY') {
- fatal('500 Internal Error',
- 'Configuration error: arguments to external diff tools must ' .
- 'be given as array refs. See "<code>%s</code>" in ' .
- '<code>%%DIFF_COMMANDS</code>.',
- $diffcmd->{name});
- }
-
- (my $cvsname = $where) =~ s/\.diff$//;
-
- # Create two temporary files with the two revisions
- my $temp_fn1 = checkout_to_temp($cvsroot, $cvsname, $rev1);
- my $temp_fn2 = checkout_to_temp($cvsroot, $cvsname, $rev2);
-
- # Execute chosen diff binary.
- local (*DIFF_OUT);
- my @cmd = ($diffcmd->{cmd});
- push(@cmd, @{$diffcmd->{args}}) if $diffcmd->{args};
- push(@cmd, $temp_fn1, $temp_fn2);
- my ($h, $err) = startproc(\@cmd, \"", '>pipe', \*DIFF_OUT);
- if (!$h) {
- unlink($temp_fn1);
- unlink($temp_fn2);
- fatal('500 Internal Error',
- 'Diff failure (exit status %s), output: <pre>%s</pre>',
- $? >> 8 || -1, $err);
- }
-
- http_header($diffcmd->{type} || 'text/plain');
- local $/ = undef;
- print <DIFF_OUT>;
- $h->finish();
- unlink($temp_fn1);
- unlink($temp_fn2);
-
- exit;
- }
-
- #
- # Normal CVS diff.
- #
-
$f = $DEFAULTVALUE{f} || 'u' if ($f =~ /^ext\d*$/);
my $difftype = $DIFFTYPES{$f};
if (!$difftype) {
@@ -2647,13 +2592,6 @@ sub getDiffLinks($$$)
&link(htmlquote(lc($DIFFTYPES{$difftype}{descr})), "$url;f=$f"));
}
}
- if (my $extdiffs = $DIFF_COMMANDS{lc($mimetype)}) {
- for my $i (0 .. scalar(@$extdiffs)-1) {
- my $extdiff = $extdiffs->[$i];
- push(@links, &link(htmlquote($extdiff->{name}), "$url;f=ext$i"))
- if ($extdiff->{cmd} && $extdiff->{name});
- }
- }
return @links;
}
@@ -3770,37 +3708,6 @@ sub runproc(@)
$errormsg = "'@{$_[0]}' failed: $@";
}
return ($exitcode, $errormsg);
-}
-
-#
-# Check out a file to a temporary file.
-#
-sub checkout_to_temp($$$)
-{
- my ($cvsroot, $cvsname, $rev) = @_;
-
- # Pipe given cvs file into a temporary place.
- my ($temp_fh, $temp_fn) = tempfile('.cvsweb.XXXXXXXX', DIR => tmpdir());
-
- my @cmd = ($CMD{cvs}, @cvs_options, '-Qd', $cvsroot,
- 'co', '-p', "-r$rev", $cvsname);
-
- local (*DIFF_OUT);
- my ($h, $err) = startproc(\@cmd, \"", '>pipe', \*DIFF_OUT);
- if ($h) {
- local $/ = undef;
- print $temp_fh <DIFF_OUT>;
- $h->finish();
- close($temp_fh);
- } else {
- close($temp_fh);
- unlink($temp_fn);
- fatal('500 Internal Error',
- 'Checkout failure (exit status %s), output: <pre>%s</pre>',
- $? >> 8 || -1, $err);
- }
-
- return $temp_fn;
}
#
Index: INSTALL
===================================================================
RCS file: /home/cvs/mandoc/cvsweb/INSTALL,v
retrieving revision 4.9
retrieving revision 4.10
diff -LINSTALL -LINSTALL -u -p -r4.9 -r4.10
--- INSTALL
+++ INSTALL
@@ -176,6 +176,3 @@ The following configuration variables in
%ICONS has a new entry: binfile for binary files (-kb keyword
substitution).
-
- %DIFF_COMMANDS is new, it is used to configure external per file type
- diff commands.
Index: cvsweb.conf
===================================================================
RCS file: /home/cvs/mandoc/cvsweb/cvsweb.conf,v
retrieving revision 4.24
retrieving revision 4.25
diff -Lcvsweb.conf -Lcvsweb.conf -u -p -r4.24 -r4.25
--- cvsweb.conf
+++ cvsweb.conf
@@ -177,28 +177,6 @@ $hr_ignwhite = 0;
#
$hr_ignkeysubst = 1;
-# Custom per MIME type diff tools, used for comparing binary files such as
-# spreadsheets, images etc. Each key is a MIME type in lowercase.
-# Each value is an array ref of available diff tools for that type, each of
-# which is a hash ref with values (mandatory where default not listed):
-# name: the name to show in the UI for this diff type
-# cmd: full path to executable
-# args: arguments as an array ref (not string!, defaults to no arguments)
-# type: output MIME type (defaults to text/plain)
-#
-%DIFF_COMMANDS = (
- #'text/xml' => [
- # { name => 'XMLdiff',
- # cmd => $CMD{xmldiff},
- # },
- # { name => 'XMLdiff (XUpdate)',
- # cmd => $CMD{xmldiff},
- # args => [ qw(-x) ],
- # type => 'text/xml',
- # },
- #],
-);
-
#
# Mime types
#
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-11-29 18:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 18:50 cvsweb: Delete support for external %DIFF_COMMANDS schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).