Commit fbd3e56da787d18e7a8794580d0e95b7669d1bc4
1 parent
19608ec1
Ignore -- at the top level arg parser (fixes #652)
This was unintended behavior that was added back for backward compatibility. It is intentionally undocumented.
Showing
4 changed files
with
18 additions
and
3 deletions
ChangeLog
| 1 | 1 | 2022-02-15 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | |
| 3 | + * Bug fix: 10.6.0 inadvertently removed an unknown/undocumented | |
| 4 | + CLI parsing feature, which has been restored in 10.6.2. Fixes #652. | |
| 5 | + | |
| 3 | 6 | * Don't map 0x18 through 0x1f, 0x7f, 0x9f, or 0xad as fixed points |
| 4 | 7 | when transcoding UTF-8 to PDFDoc. These codepoints have different |
| 5 | 8 | meanings in those two encoding systems. Fixes #650. | ... | ... |
libqpdf/QPDFArgParser.cc
| ... | ... | @@ -554,8 +554,7 @@ QPDFArgParser::parseArgs() |
| 554 | 554 | bool have_parameter = false; |
| 555 | 555 | std::string o_arg(arg); |
| 556 | 556 | std::string arg_s(arg); |
| 557 | - if ((strcmp(arg, "--") == 0) && | |
| 558 | - (this->m->option_table != &this->m->main_option_table)) | |
| 557 | + if (strcmp(arg, "--") == 0) | |
| 559 | 558 | { |
| 560 | 559 | // Special case for -- option, which is used to break out |
| 561 | 560 | // of subparsers. | ... | ... |
libqpdf/QPDFJob_argv.cc
| ... | ... | @@ -67,6 +67,11 @@ ArgParser::initOptionTables() |
| 67 | 67 | this->ap.addFinalCheck([this](){c_main->checkConfiguration();}); |
| 68 | 68 | // add_help is defined in auto_job_help.hh |
| 69 | 69 | add_help(this->ap); |
| 70 | + // Special case: ignore -- at the top level. This undocumented | |
| 71 | + // behavior is for backward compatibility; it was unintentionally | |
| 72 | + // the case prior to 10.6, and some users were relying on it. | |
| 73 | + this->ap.selectMainOptionTable(); | |
| 74 | + this->ap.addBare("--", [](){}); | |
| 70 | 75 | } |
| 71 | 76 | |
| 72 | 77 | void | ... | ... |
qpdf/qtest/qpdf.test
| ... | ... | @@ -149,7 +149,7 @@ foreach my $c (@completion_tests) |
| 149 | 149 | show_ntests(); |
| 150 | 150 | # ---------- |
| 151 | 151 | $td->notify("--- Argument Parsing ---"); |
| 152 | -$n_tests += 12; | |
| 152 | +$n_tests += 13; | |
| 153 | 153 | |
| 154 | 154 | $td->runtest("required argument", |
| 155 | 155 | {$td->COMMAND => "qpdf --password minimal.pdf"}, |
| ... | ... | @@ -211,6 +211,14 @@ $td->runtest("duplicated pages password", |
| 211 | 211 | {$td->REGEXP => ".*password already specified.*", |
| 212 | 212 | $td->EXIT_STATUS => 2}, |
| 213 | 213 | $td->NORMALIZE_NEWLINES); |
| 214 | +# Ignoring -- at the top level was never intended but turned out to | |
| 215 | +# have been there for a long time so that people relied on it. It is | |
| 216 | +# intentionally not documented. | |
| 217 | +$td->runtest("ignore -- at top level", | |
| 218 | + {$td->COMMAND => "qpdf -- --check -- minimal.pdf --"}, | |
| 219 | + {$td->REGEXP => ".*No syntax or stream encoding errors found.*", | |
| 220 | + $td->EXIT_STATUS => 0}, | |
| 221 | + $td->NORMALIZE_NEWLINES); | |
| 214 | 222 | |
| 215 | 223 | show_ntests(); |
| 216 | 224 | # ---------- | ... | ... |