aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2024-02-17 21:42:10 +0100
committerJay Berkenbilt <ejb@ql.org>2024-02-17 22:13:42 +0100
commit7bc52c5728591674f864ce7ff10c4bbe24787333 (patch)
tree7e12b911eeabc3542af984a04772c56f392a57b6
parent072623d6e80129fe6a716a60bb85200f7300acd5 (diff)
downloadqpdf-7bc52c5728591674f864ce7ff10c4bbe24787333.tar.zst
set page labels: detect start page < 1 (fixes #939)
-rw-r--r--libqpdf/QPDFJob_config.cc3
-rw-r--r--qpdf/qtest/page-labels.test4
2 files changed, 5 insertions, 2 deletions
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index e9084e85..107abf7c 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -1139,6 +1139,9 @@ QPDFJob::Config::setPageLabels(const std::vector<std::string>& specs)
}
auto start_num = match[3].matched ? QUtil::string_to_int(match[3].str().c_str()) : 1;
+ if (start_num < 1) {
+ usage("starting page number must be >= 1");
+ }
auto prefix = match[4].matched ? match[4].str() : "";
// We can't check ordering until we know how many pages there are, so that is delayed until
// near the end.
diff --git a/qpdf/qtest/page-labels.test b/qpdf/qtest/page-labels.test
index 9927437b..b90acd61 100644
--- a/qpdf/qtest/page-labels.test
+++ b/qpdf/qtest/page-labels.test
@@ -33,8 +33,8 @@ $td->runtest("no page labels",
my @errors = (
["quack", ".*page label spec must be.*"],
["5:r 10:D", ".*the first page .*must start with page 1.*"],
- ["1:r 10:D 31:A",
- ".*page 31 is more than the total number of pages \\(30\\).*"],
+ ["1:r 10:D 31:A", ".*page 31 is more than the total number of pages \\(30\\).*"],
+ ["1:r/0", ".*starting page number must be >= 1.*"],
);
$n_tests += scalar(@errors);