diff options
-rw-r--r-- | Build/source/texk/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/ChangeLog | 11 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/Makefile.am | 5 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/Makefile.in | 2 | ||||
-rwxr-xr-x | Build/source/texk/dvipsk/quotecmd-test.pl | 31 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/search.c | 31 | ||||
-rw-r--r-- | Build/source/texk/dvipsk/testdata/quotecmd.tex | 16 | ||||
-rw-r--r-- | Build/source/texk/tests/common-test.pl (renamed from Build/source/texk/web2c/tests/common-test.pl) | 8 | ||||
-rw-r--r-- | Build/source/texk/web2c/ChangeLog | 6 | ||||
-rwxr-xr-x | Build/source/texk/web2c/tests/bibtex-openout-test.pl | 7 | ||||
-rwxr-xr-x | Build/source/texk/web2c/tests/write18-quote-test.pl | 9 | ||||
-rw-r--r-- | Build/source/texk/web2c/tests/write18-quote.tex | 3 |
12 files changed, 102 insertions, 31 deletions
diff --git a/Build/source/texk/ChangeLog b/Build/source/texk/ChangeLog index df8a90cd07b..c08344b9ca7 100644 --- a/Build/source/texk/ChangeLog +++ b/Build/source/texk/ChangeLog @@ -1,3 +1,7 @@ +2010-02-18 Karl Berry <karl@tug.org> + + * tests: new subdir for common test files. + 2009-10-08 Peter Breitenlohner <peb@mppmu.mpg.de> * Import bibtexu (static icu libs only). diff --git a/Build/source/texk/dvipsk/ChangeLog b/Build/source/texk/dvipsk/ChangeLog index 5d53f732b94..abe63992c15 100644 --- a/Build/source/texk/dvipsk/ChangeLog +++ b/Build/source/texk/dvipsk/ChangeLog @@ -1,3 +1,14 @@ +2010-02-18 Karl Berry <karl@tug.org> + + * Makefile.am (TESTS): add quotecmd-test.pl. + * quotecmd-test.pl, + * testdata/quotecmd.tex: new files. + * search.c (search): selfautoloc gunzip, and quote name before + calling popen. + (kpse_quote_name, kpse_self_autoloc_prog): new fns, + only temporarily here until we factor out the common code from + texmfmp.c. + 2010-02-12 Peter Breitenlohner <peb@mppmu.mpg.de> * dvips.c (main): Add '#if defined(KPSE_DEBUG)' to allow diff --git a/Build/source/texk/dvipsk/Makefile.am b/Build/source/texk/dvipsk/Makefile.am index 5eb0b649c5e..b55888430fe 100644 --- a/Build/source/texk/dvipsk/Makefile.am +++ b/Build/source/texk/dvipsk/Makefile.am @@ -109,9 +109,8 @@ EXTRA_DIST = $(dist_prologues) texc.script CLEANFILES = $(prologues) texc.lpro -## dvips test -## -TESTS = beginfontk1.test dvips.test pfbincl.test +## dvips tests +TESTS = beginfontk1.test dvips.test pfbincl.test quotecmd-test.pl TESTS_ENVIRONMENT = TEXMFCNF=$(srcdir)/../kpathsea TEXCONFIG=$(srcdir)/testdata TESTS_ENVIRONMENT += TEXFONTS=$(srcdir)/testdata diff --git a/Build/source/texk/dvipsk/Makefile.in b/Build/source/texk/dvipsk/Makefile.in index e13d2a83429..9237a92bf57 100644 --- a/Build/source/texk/dvipsk/Makefile.in +++ b/Build/source/texk/dvipsk/Makefile.in @@ -401,7 +401,7 @@ EXTRA_DIST = $(dist_prologues) texc.script beginfontk1.test dvips.test \ mvs psfonts.map tex vmcms vms CLEANFILES = $(prologues) texc.lpro dvipstst.ps missfont.log mtest.ps \ pfbincl.ps -TESTS = beginfontk1.test dvips.test pfbincl.test +TESTS = beginfontk1.test dvips.test pfbincl.test quotecmd-test.pl TESTS_ENVIRONMENT = TEXMFCNF=$(srcdir)/../kpathsea \ TEXCONFIG=$(srcdir)/testdata TEXFONTS=$(srcdir)/testdata \ TEXPSHEADERS=$(srcdir)/testdata diff --git a/Build/source/texk/dvipsk/quotecmd-test.pl b/Build/source/texk/dvipsk/quotecmd-test.pl new file mode 100755 index 00000000000..2d1f90da004 --- /dev/null +++ b/Build/source/texk/dvipsk/quotecmd-test.pl @@ -0,0 +1,31 @@ +#!/usr/bin/env perl +# $Id: bibtex-openout-test.pl 16507 2009-12-25 01:19:05Z karl $ +# Public domain. Originally written 2010, Karl Berry. +# Check that dvips quotes external command arguments. + +BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `dirname $0`); } +require "$srcdir/../tests/common-test.pl"; + +exit (&main ()); + +sub main +{ + # create the weirdly-named file which dvips executes with popen. + # quotecmd.tex itself also creates it, but we don't want to run TeX in + # this test, nor do we want such a weirdly-named file in our + # repository, so create it here. Leave it in place, so we can run the + # program under the debugging if we need to. + my $weirdf = ' 2>&1 | echo badnews >pwned.txt #.gz'; + unlink ($weirdf); # ensure no leftover + open (WEIRDF, ">", $weirdf); + close (WEIRDF) || die "open(weird file name) failed: $!"; + + $badfile = "pwned.txt"; # will be created if program is broken + unlink ($badfile); # ensure no leftover from previous test + + my @args = ("$srcdir/testdata/quotecmd.dvi", qw(-o /dev/null)); + my $ret = &test_run ("./dvips", @args); + + my $bad = -f $badfile; # file should not have been created + return $bad; +} diff --git a/Build/source/texk/dvipsk/search.c b/Build/source/texk/dvipsk/search.c index da760c66d31..083e8ddd4ba 100644 --- a/Build/source/texk/dvipsk/search.c +++ b/Build/source/texk/dvipsk/search.c @@ -7,6 +7,10 @@ */ #include "dvips.h" /* The copyright notice in that file is included too! */ +#ifndef KPATHSEA +"goodbye, search.c can only be compiled with -DKPATHSEA" +#endif + #include "protos_add.h" /* external declarations */ #include <kpathsea/c-ctype.h> @@ -22,9 +26,9 @@ int to_close ; /* use fclose or pclose? */ char *realnameoffile ; -/* Return safely quoted version of NAME. That means as "..." on Windows - and '...' on Unix, with any occurrences of the quote char quoted with - a \. Result is always in new memory, and NAME is unchanged. */ +/* Return safely quoted version of NAME. That means using "..." on + Windows and '...' on Unix, with any occurrences of the quote char + quoted with a \. Result is always in new memory; NAME is unchanged. */ #ifdef WIN32 #define QUOTE '"' @@ -48,7 +52,7 @@ kpse_quote_name (const char *name) *q++ = QUOTE; *q = 0; - return q; + return quoted; } @@ -56,9 +60,9 @@ kpse_quote_name (const char *name) changed to \. On Unix, return a copy of PROG. Result is always in new memory. No safeness or other quoting is done on PROG. - This is necessary because Windows always wants to run programs out of - the current directory. So for security, we want to ensure that we - are invoking programs from our own binary directory, not via PATH. */ + This is necessary because Windows likes to run programs out of the + current directory. So for security, we want to ensure that we are + invoking programs from our own binary directory, not via PATH. */ static char * kpse_selfautoloc_prog (const char *prog) @@ -75,6 +79,7 @@ kpse_selfautoloc_prog (const char *prog) /* Prepend that to PROG. */ ret = concat3 (selfautoloc, "\\", prog); + free (selfautoloc); #else /* not WIN32 */ ret = xstrdup (prog); @@ -97,7 +102,8 @@ search(kpse_file_format_type format, const char *file, const char *mode) if (secure == 2) { #endif /* an absolute path is denied */ - if (kpse_absolute_p (file, false)) return NULL; + if (kpse_absolute_p (file, false)) + return NULL; if (file[0] == '.' && file[1] == '.' && IS_DIR_SEP(file[2])) { /* a relative path starting with ../ is denied */ @@ -129,14 +135,14 @@ search(kpse_file_format_type format, const char *file, const char *mode) && ((len > 2 && FILESTRCASEEQ (found_name + len - 2, ".Z")) || (len > 3 && FILESTRCASEEQ (found_name + len - 3, ".gz")))) { /* automatically but safely decompress. */ -/* char *quoted_name = kpse_quote_name (found_name); */ + char *quoted_name = kpse_quote_name (found_name); char *cmd; char *prog = kpse_selfautoloc_prog (GUNZIP); - cmd = concat3 (prog, " -c ", found_name); + cmd = concat3 (prog, " -c ", quoted_name); ret = popen (cmd, "r"); to_close = USE_PCLOSE; free (cmd); -/* free (quoted_name); */ + free (quoted_name); free (prog); } else { ret = fopen (found_name, mode); @@ -161,7 +167,8 @@ search(kpse_file_format_type format, const char *file, const char *mode) FILE * -pksearch(const char *file, const char *mode, halfword dpi, char **name_ret, int *dpi_ret) +pksearch(const char *file, const char *mode, halfword dpi, + char **name_ret, int *dpi_ret) { FILE *ret; kpse_glyph_file_type font_file; diff --git a/Build/source/texk/dvipsk/testdata/quotecmd.tex b/Build/source/texk/dvipsk/testdata/quotecmd.tex new file mode 100644 index 00000000000..a294e703aa1 --- /dev/null +++ b/Build/source/texk/dvipsk/testdata/quotecmd.tex @@ -0,0 +1,16 @@ +% $Id: write18-quote.tex 16695 2010-01-13 01:18:02Z karl $ +% Public domain. Originally written 2009, Alexander Cherepanov. + +\catcode`\# = 12 +\def\cmd{" 2>&1 | echo badnews > pwned.txt #.gz"} + +% create this weirdly-named file. +\catcode0 = 12 +\immediate\openout1 \cmd^^@ +\immediate\closeout1 + +% write out a special referring to it. +% if it exists when dvips is run, it will be executed with popen. +\special{psfile=\cmd} +\nopagenumbers +\end diff --git a/Build/source/texk/web2c/tests/common-test.pl b/Build/source/texk/tests/common-test.pl index 725ba55b624..414168a9648 100644 --- a/Build/source/texk/web2c/tests/common-test.pl +++ b/Build/source/texk/tests/common-test.pl @@ -1,7 +1,7 @@ -# $Id$ -# Copyright 2010 Karl Berry <tex-live@tug.org>. -# You may freely use, modify and/or distribute this file. -# Common definitions for Perl tests in TeX Live. +# $Id: common-test.pl 16695 2010-01-13 01:18:02Z karl $ +# Public domain. Originally written 2010, Karl Berry. +# Common definitions for Perl tests in TeX Live. We want to use Perl to +# have a chance of running the tests on Windows. $ENV{"TEXMFCNF"} = "$srcdir/../kpathsea"; $ENV{"BIBINPUTS"} = "$srcdir/tests"; diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog index ffbb8c43628..92d2e36ba34 100644 --- a/Build/source/texk/web2c/ChangeLog +++ b/Build/source/texk/web2c/ChangeLog @@ -1,3 +1,9 @@ +2010-02-18 Karl Berry <karl@tug.org> + + * tests/common-test.pl: moved to texk/tests. + * tests/write18-quote-test.pl, + * tests/bibtex-openout-test.pl: change calls. + 2010-02-01 Karl Berry <karl@tug.org> * doc/web2c.texi (Output file location): mention that TEXMFOUTPUT diff --git a/Build/source/texk/web2c/tests/bibtex-openout-test.pl b/Build/source/texk/web2c/tests/bibtex-openout-test.pl index fc8dabfc846..45fd92d1b6f 100755 --- a/Build/source/texk/web2c/tests/bibtex-openout-test.pl +++ b/Build/source/texk/web2c/tests/bibtex-openout-test.pl @@ -1,11 +1,10 @@ #!/usr/bin/env perl # $Id$ -# Copyright 2009, 2010 Karl Berry <tex-live@tug.org>. -# You may freely use, modify and/or distribute this file. +# Public domain. Originally written 2010, Karl Berry. # Check that bibtex respects openout_any. -BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `pwd`); } -require "$srcdir/tests/common-test.pl"; +BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `dirname $0`); } +require "$srcdir/../tests/common-test.pl"; exit (&main ()); diff --git a/Build/source/texk/web2c/tests/write18-quote-test.pl b/Build/source/texk/web2c/tests/write18-quote-test.pl index 74256516b73..d0daabdd054 100755 --- a/Build/source/texk/web2c/tests/write18-quote-test.pl +++ b/Build/source/texk/web2c/tests/write18-quote-test.pl @@ -1,11 +1,10 @@ #!/usr/bin/env perl # $Id$ -# Copyright 2010 Karl Berry <tex-live@tug.org>. -# You may freely use, modify and/or distribute this file. +# Public domain. Originally written 2010, Karl Berry. # Check that restricted shell invocation doesn't misquote. -BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `pwd`); } -require "$srcdir/tests/common-test.pl"; +BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `dirname $0`); } +require "$srcdir/../tests/common-test.pl"; exit (&main ()); @@ -14,7 +13,7 @@ sub main $badfile = "write18-quote-newfile.tex"; unlink ($badfile); # ensure no leftover from previous test - my @args = qw(-ini -shell-restricted $srcdir/tests/write18-quote.tex); + my @args = (qw(-ini -shell-restricted), "$srcdir/tests/write18-quote.tex"); my $ret = &test_run ("./tex", @args); my $bad = -f $badfile; # file should not have been created diff --git a/Build/source/texk/web2c/tests/write18-quote.tex b/Build/source/texk/web2c/tests/write18-quote.tex index d766ac4f808..dcfe6cb1e92 100644 --- a/Build/source/texk/web2c/tests/write18-quote.tex +++ b/Build/source/texk/web2c/tests/write18-quote.tex @@ -1,6 +1,5 @@ % $Id$ -% Copyright 2010 Karl Berry <tex-live@tug.org>. -% You may freely use, modify and/or distribute this file. +% Public domain. Originally written 2010, Karl Berry. \catcode`\{=1 \catcode`\}=2 % allow for running with initex. |