aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-02-15 21:34:35 +0100
committerJay Berkenbilt <ejb@ql.org>2022-02-15 22:13:12 +0100
commitfbd3e56da787d18e7a8794580d0e95b7669d1bc4 (patch)
tree33536b518187508d284771504f09c90c70ae5201
parent19608ec151f218aa5f7c47a2d1e497d88acbb3be (diff)
downloadqpdf-fbd3e56da787d18e7a8794580d0e95b7669d1bc4.tar.zst
Ignore -- at the top level arg parser (fixes #652)
This was unintended behavior that was added back for backward compatibility. It is intentionally undocumented.
-rw-r--r--ChangeLog3
-rw-r--r--libqpdf/QPDFArgParser.cc3
-rw-r--r--libqpdf/QPDFJob_argv.cc5
-rw-r--r--qpdf/qtest/qpdf.test10
4 files changed, 18 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index b63a785d..894504c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2022-02-15 Jay Berkenbilt <ejb@ql.org>
+ * 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();
# ----------