mirror of
https://github.com/qpdf/qpdf.git
synced 2024-05-30 08:50:51 +00:00
Disallow --empty with --replace-input (fixes #728)
This commit is contained in:
parent
fa15042ce9
commit
31396f61c9
|
@ -683,7 +683,13 @@ QPDFJob::getExitCode() const
|
||||||
void
|
void
|
||||||
QPDFJob::checkConfiguration()
|
QPDFJob::checkConfiguration()
|
||||||
{
|
{
|
||||||
|
// Do final checks for command-line consistency. (I always think
|
||||||
|
// this is called doFinalChecks, so I'm putting that in a
|
||||||
|
// comment.)
|
||||||
|
|
||||||
if (m->replace_input) {
|
if (m->replace_input) {
|
||||||
|
// Check for --empty appears later after we have checked
|
||||||
|
// m->infilename.
|
||||||
if (m->outfilename) {
|
if (m->outfilename) {
|
||||||
usage("--replace-input may not be used when"
|
usage("--replace-input may not be used when"
|
||||||
" an output file is specified");
|
" an output file is specified");
|
||||||
|
@ -700,6 +706,8 @@ QPDFJob::checkConfiguration()
|
||||||
}
|
}
|
||||||
if (m->infilename == nullptr) {
|
if (m->infilename == nullptr) {
|
||||||
usage("an input file name is required");
|
usage("an input file name is required");
|
||||||
|
} else if (m->replace_input && (strlen(m->infilename.get()) == 0)) {
|
||||||
|
usage("--replace-input may not be used with --empty");
|
||||||
} else if (
|
} else if (
|
||||||
m->require_outfile && (m->outfilename == nullptr) &&
|
m->require_outfile && (m->outfilename == nullptr) &&
|
||||||
(!m->replace_input)) {
|
(!m->replace_input)) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ cleanup();
|
||||||
|
|
||||||
my $td = new TestDriver('arg-parsing');
|
my $td = new TestDriver('arg-parsing');
|
||||||
|
|
||||||
my $n_tests = 16;
|
my $n_tests = 17;
|
||||||
|
|
||||||
$td->runtest("required argument",
|
$td->runtest("required argument",
|
||||||
{$td->COMMAND => "qpdf --password minimal.pdf"},
|
{$td->COMMAND => "qpdf --password minimal.pdf"},
|
||||||
|
@ -102,6 +102,11 @@ $td->runtest("ignore -- at top level",
|
||||||
{$td->REGEXP => ".*No syntax or stream encoding errors found.*",
|
{$td->REGEXP => ".*No syntax or stream encoding errors found.*",
|
||||||
$td->EXIT_STATUS => 0},
|
$td->EXIT_STATUS => 0},
|
||||||
$td->NORMALIZE_NEWLINES);
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
$td->runtest("empty and replace-input",
|
||||||
|
{$td->COMMAND => "qpdf --empty --replace-input"},
|
||||||
|
{$td->REGEXP => ".*--replace-input may not be used with --empty.*",
|
||||||
|
$td->EXIT_STATUS => 2},
|
||||||
|
$td->NORMALIZE_NEWLINES);
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
$td->report($n_tests);
|
$td->report($n_tests);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user