aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--job.sums8
-rw-r--r--job.yml1
-rw-r--r--libqpdf/QPDFJob_json.cc11
-rw-r--r--libqpdf/qpdf/auto_job_json_decl.hh2
-rw-r--r--libqpdf/qpdf/auto_job_json_init.hh2
-rw-r--r--libqpdf/qpdf/auto_job_schema.hh4
-rw-r--r--qpdf/qtest/qpdf.test21
-rw-r--r--qpdf/qtest/qpdf/remove-multiple-attachments-json.out3
-rw-r--r--qpdf/qtest/qpdf/remove-multiple-attachments.json10
-rw-r--r--qpdf/qtest/qpdf/remove-multiple-attachments.out3
-rw-r--r--qpdf/qtest/qpdf/remove-multiple-attachments.pdfbin0 -> 1341 bytes
12 files changed, 64 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ab6f4da..5615db2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2022-04-24 Jay Berkenbilt <ejb@ql.org>
+ * Bug fix: "removeAttachment" in the job JSON now takes an array
+ of strings instead of a string. It should have taken an array of
+ strings since the corresponding command-line argument,
+ --remove-attachment, is repeatable. Fixes #693.
+
* Deprecate QPDFObjectHandle::replaceOrRemoveKey -- it does and
always has done the same thing as replaceKey.
diff --git a/job.sums b/job.sums
index 5fe5ff6c..e1fce3af 100644
--- a/job.sums
+++ b/job.sums
@@ -6,12 +6,12 @@ include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a3
include/qpdf/auto_job_c_main.hh 4ba9bcb8be945f6a3ffa0df3becdb8488b6eaf45dd914d8b714d948e17b5ad5d
include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c18911614fe8e568ec
include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1
-job.yml 06a0b29f63c1622a0c6270d15d848a42084a6424e4b98d5d4942a8ec903b7a70
+job.yml c2937bb06818fc3bffe54c6c069a4a06db7f3c841958c2da1b2f4a33978fd24a
libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df
libqpdf/qpdf/auto_job_help.hh a7d7edc3b270f2488778426646bb68dcad036727db4be87d1da9993e2a007634
libqpdf/qpdf/auto_job_init.hh 6bd71c2ae4ba80e81fe5ae5517ba72abf53a3146f66864f99eeebc7d224998a5
-libqpdf/qpdf/auto_job_json_decl.hh 30058d744cfb0d1b5e5bd2830e1c7b24713ee39c97c4ccb723dbbae1f9fab61c
-libqpdf/qpdf/auto_job_json_init.hh d3885830362c4337822bf9bc3d177b50149ba403a26de0e69d37f7751cb5d538
-libqpdf/qpdf/auto_job_schema.hh 18a3780671d95224cb9a27dcac627c421cae509d59f33a63e6bda0ab53cce923
+libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297
+libqpdf/qpdf/auto_job_json_init.hh 06d51f11c117011256e175386eee9946441f3c22b49dd91fc591bbc1fa3bbeec
+libqpdf/qpdf/auto_job_schema.hh 43273b9edfc48b1f4cccbff1d2b31916a9057c474ef97d2936b2f1f14170885b
manual/_ext/qpdf.py e9ac9d6c70642a3d29281ee5ad92ae2422dee8be9306fb8a0bc9dba0ed5e28f3
manual/cli.rst aa44cbe7b6281ee05dc8b19ee1b12ca770503681ffc8ba90e795fc3c3b55153d
diff --git a/job.yml b/job.yml
index 6e6b5dd3..7d830b1a 100644
--- a/job.yml
+++ b/job.yml
@@ -372,6 +372,7 @@ json:
moddate:
replace:
remove-attachment:
+ - null
copy-attachments-from:
- _file: "file to copy attachments from"
CopyAtt.password:
diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc
index c0247e0b..e529439a 100644
--- a/libqpdf/QPDFJob_json.cc
+++ b/libqpdf/QPDFJob_json.cc
@@ -413,6 +413,17 @@ Handlers::setupAddAttachmentFile()
}
void
+Handlers::beginRemoveAttachmentArray(JSON)
+{
+ // nothing needed
+}
+
+void
+Handlers::endRemoveAttachmentArray()
+{
+ // nothing needed
+}
+void
Handlers::beginCopyAttachmentsFromArray(JSON)
{
// nothing needed
diff --git a/libqpdf/qpdf/auto_job_json_decl.hh b/libqpdf/qpdf/auto_job_json_decl.hh
index 7f996928..f02dc657 100644
--- a/libqpdf/qpdf/auto_job_json_decl.hh
+++ b/libqpdf/qpdf/auto_job_json_decl.hh
@@ -29,6 +29,8 @@ void endAddAttachmentArray();
void beginAddAttachment(JSON);
void endAddAttachment();
void setupAddAttachmentFile();
+void beginRemoveAttachmentArray(JSON);
+void endRemoveAttachmentArray();
void beginCopyAttachmentsFromArray(JSON);
void endCopyAttachmentsFromArray();
void beginCopyAttachmentsFrom(JSON);
diff --git a/libqpdf/qpdf/auto_job_json_init.hh b/libqpdf/qpdf/auto_job_json_init.hh
index 2f807469..3c83ec2d 100644
--- a/libqpdf/qpdf/auto_job_json_init.hh
+++ b/libqpdf/qpdf/auto_job_json_init.hh
@@ -327,7 +327,9 @@ popHandler(); // key: replace
popHandler(); // array: .addAttachment[]
popHandler(); // key: addAttachment
pushKey("removeAttachment");
+beginArray(bindJSON(&Handlers::beginRemoveAttachmentArray), bindBare(&Handlers::endRemoveAttachmentArray)); // .removeAttachment[]
addParameter([this](std::string const& p) { c_main->removeAttachment(p); });
+popHandler(); // array: .removeAttachment[]
popHandler(); // key: removeAttachment
pushKey("copyAttachmentsFrom");
beginArray(bindJSON(&Handlers::beginCopyAttachmentsFromArray), bindBare(&Handlers::endCopyAttachmentsFromArray)); // .copyAttachmentsFrom[]
diff --git a/libqpdf/qpdf/auto_job_schema.hh b/libqpdf/qpdf/auto_job_schema.hh
index ca9fc1e1..557af9ee 100644
--- a/libqpdf/qpdf/auto_job_schema.hh
+++ b/libqpdf/qpdf/auto_job_schema.hh
@@ -111,7 +111,9 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
"replace": "replace attachment with same key"
}
],
- "removeAttachment": "remove an embedded file",
+ "removeAttachment": [
+ "remove an embedded file"
+ ],
"copyAttachmentsFrom": [
{
"file": "file to copy attachments from",
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 5bf6be76..8878aa31 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -723,7 +723,7 @@ $td->runtest("check overlay with no resources output",
show_ntests();
# ----------
$td->notify("--- File Attachments ---");
-$n_tests += 33;
+$n_tests += 37;
open(F, ">auto-txt") or die;
print F "from file";
@@ -907,6 +907,25 @@ $td->runtest("check dates",
{$td->REGEXP => ".*CreationDate \\(D:\\d+.*ModDate \\(D:\\d+.*",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
+$td->runtest("remove multiple attachments",
+ {$td->COMMAND =>
+ "qpdf --verbose --static-id add-attachments-1.pdf a.pdf" .
+ " --remove-attachment=auto-1 --remove-attachment=auto-Two"},
+ {$td->FILE => "remove-multiple-attachments.out",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("check output",
+ {$td->FILE => "a.pdf"},
+ {$td->FILE => "remove-multiple-attachments.pdf"});
+$td->runtest("remove multiple attachments (json)",
+ {$td->COMMAND =>
+ "qpdf --job-json-file=remove-multiple-attachments.json"},
+ {$td->FILE => "remove-multiple-attachments-json.out",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+$td->runtest("check output",
+ {$td->FILE => "b.pdf"},
+ {$td->FILE => "remove-multiple-attachments.pdf"});
show_ntests();
# ----------
diff --git a/qpdf/qtest/qpdf/remove-multiple-attachments-json.out b/qpdf/qtest/qpdf/remove-multiple-attachments-json.out
new file mode 100644
index 00000000..3563f1f8
--- /dev/null
+++ b/qpdf/qtest/qpdf/remove-multiple-attachments-json.out
@@ -0,0 +1,3 @@
+qpdf: removed attachment auto-1
+qpdf: removed attachment auto-Two
+qpdf: wrote file b.pdf
diff --git a/qpdf/qtest/qpdf/remove-multiple-attachments.json b/qpdf/qtest/qpdf/remove-multiple-attachments.json
new file mode 100644
index 00000000..ea79cdf5
--- /dev/null
+++ b/qpdf/qtest/qpdf/remove-multiple-attachments.json
@@ -0,0 +1,10 @@
+{
+ "verbose": "",
+ "staticId": "",
+ "inputFile": "add-attachments-1.pdf",
+ "outputFile": "b.pdf",
+ "removeAttachment": [
+ "auto-1",
+ "auto-Two"
+ ]
+}
diff --git a/qpdf/qtest/qpdf/remove-multiple-attachments.out b/qpdf/qtest/qpdf/remove-multiple-attachments.out
new file mode 100644
index 00000000..e114eff5
--- /dev/null
+++ b/qpdf/qtest/qpdf/remove-multiple-attachments.out
@@ -0,0 +1,3 @@
+qpdf: removed attachment auto-1
+qpdf: removed attachment auto-Two
+qpdf: wrote file a.pdf
diff --git a/qpdf/qtest/qpdf/remove-multiple-attachments.pdf b/qpdf/qtest/qpdf/remove-multiple-attachments.pdf
new file mode 100644
index 00000000..c480af1c
--- /dev/null
+++ b/qpdf/qtest/qpdf/remove-multiple-attachments.pdf
Binary files differ