diff --git a/ChangeLog b/ChangeLog index b63a785d..894504c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2022-02-15 Jay Berkenbilt + * Bug fix: 10.6.0 inadvertently removed an unknown/undocumented + CLI parsing feature, which has been restored in 10.6.2. Fixes #652. + * Don't map 0x18 through 0x1f, 0x7f, 0x9f, or 0xad as fixed points when transcoding UTF-8 to PDFDoc. These codepoints have different meanings in those two encoding systems. Fixes #650. diff --git a/libqpdf/QPDFArgParser.cc b/libqpdf/QPDFArgParser.cc index 0e072c10..868db709 100644 --- a/libqpdf/QPDFArgParser.cc +++ b/libqpdf/QPDFArgParser.cc @@ -554,8 +554,7 @@ QPDFArgParser::parseArgs() bool have_parameter = false; std::string o_arg(arg); std::string arg_s(arg); - if ((strcmp(arg, "--") == 0) && - (this->m->option_table != &this->m->main_option_table)) + if (strcmp(arg, "--") == 0) { // Special case for -- option, which is used to break out // of subparsers. diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc index 6cbbd841..b1e3da1c 100644 --- a/libqpdf/QPDFJob_argv.cc +++ b/libqpdf/QPDFJob_argv.cc @@ -67,6 +67,11 @@ ArgParser::initOptionTables() this->ap.addFinalCheck([this](){c_main->checkConfiguration();}); // add_help is defined in auto_job_help.hh add_help(this->ap); + // Special case: ignore -- at the top level. This undocumented + // behavior is for backward compatibility; it was unintentionally + // the case prior to 10.6, and some users were relying on it. + this->ap.selectMainOptionTable(); + this->ap.addBare("--", [](){}); } void diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index ecc51bb8..14205d88 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -149,7 +149,7 @@ foreach my $c (@completion_tests) show_ntests(); # ---------- $td->notify("--- Argument Parsing ---"); -$n_tests += 12; +$n_tests += 13; $td->runtest("required argument", {$td->COMMAND => "qpdf --password minimal.pdf"}, @@ -211,6 +211,14 @@ $td->runtest("duplicated pages password", {$td->REGEXP => ".*password already specified.*", $td->EXIT_STATUS => 2}, $td->NORMALIZE_NEWLINES); +# Ignoring -- at the top level was never intended but turned out to +# have been there for a long time so that people relied on it. It is +# intentionally not documented. +$td->runtest("ignore -- at top level", + {$td->COMMAND => "qpdf -- --check -- minimal.pdf --"}, + {$td->REGEXP => ".*No syntax or stream encoding errors found.*", + $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); show_ntests(); # ----------