aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2023-12-24 13:12:32 +0100
committerJay Berkenbilt <ejb@ql.org>2023-12-24 13:36:07 +0100
commit4ca185fd96dfd3c7a8d89d3afd8093a26acf178b (patch)
treea50f15d2e151cd9f5b18bae2dc5405f650795186 /libqpdf
parent2f37633b923e0294acd894454a95d2a9ee1d36a9 (diff)
downloadqpdf-4ca185fd96dfd3c7a8d89d3afd8093a26acf178b.tar.zst
Remove --disable-signatures; incorporate into --remove-restrictions
Rather than adding yet another flag that is almost never useful on its own, just have --remove-restrictions disable digital signatures. The operations are still separate in the API.
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFAcroFormDocumentHelper.cc1
-rw-r--r--libqpdf/QPDFJob.cc3
-rw-r--r--libqpdf/QPDFJob_config.cc7
-rw-r--r--libqpdf/qpdf/auto_job_help.hh49
-rw-r--r--libqpdf/qpdf/auto_job_init.hh1
-rw-r--r--libqpdf/qpdf/auto_job_json_init.hh3
-rw-r--r--libqpdf/qpdf/auto_job_schema.hh1
7 files changed, 23 insertions, 42 deletions
diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc
index 5fdd20ba..fb096e5e 100644
--- a/libqpdf/QPDFAcroFormDocumentHelper.cc
+++ b/libqpdf/QPDFAcroFormDocumentHelper.cc
@@ -418,6 +418,7 @@ QPDFAcroFormDocumentHelper::generateAppearancesIfNeeded()
void
QPDFAcroFormDocumentHelper::disableDigitalSignatures()
{
+ qpdf.removeSecurityRestrictions();
std::set<QPDFObjGen> to_remove;
auto fields = getFormFields();
for (auto& f: fields) {
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc
index 7b007c08..b2f905a1 100644
--- a/libqpdf/QPDFJob.cc
+++ b/libqpdf/QPDFJob.cc
@@ -2127,9 +2127,6 @@ QPDFJob::handleTransformations(QPDF& pdf)
}
};
if (m->remove_restrictions) {
- pdf.removeSecurityRestrictions();
- }
- if (m->disable_signatures) {
make_afdh();
afdh->disableDigitalSignatures();
}
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index 922d46e5..4798ce9b 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -145,13 +145,6 @@ QPDFJob::Config::deterministicId()
}
QPDFJob::Config*
-QPDFJob::Config::disableSignatures()
-{
- o.m->disable_signatures = true;
- return this;
-}
-
-QPDFJob::Config*
QPDFJob::Config::encryptionFilePassword(std::string const& parameter)
{
o.m->encryption_file_password = QUtil::make_shared_cstr(parameter);
diff --git a/libqpdf/qpdf/auto_job_help.hh b/libqpdf/qpdf/auto_job_help.hh
index 9147b601..da6520c5 100644
--- a/libqpdf/qpdf/auto_job_help.hh
+++ b/libqpdf/qpdf/auto_job_help.hh
@@ -157,15 +157,10 @@ encrypted. Normally qpdf preserves whatever encryption was
present on the input file. This option overrides that behavior.
)");
ap.addOptionHelp("--remove-restrictions", "transformation", "remove security restrictions from input file", R"(Remove restrictions associated with digitally signed PDF files.
-This may be combined with --decrypt and --disable-signatures to
-allow free editing of previously signed/encrypted files. This
-option invalidates the signature but leaves its visual
-appearance intact. See also --disable-signatures.
-)");
-ap.addOptionHelp("--disable-signatures", "transformation", "disable digital signature fields", R"(Remove all digital signature fields from a file. The appearance
-of the digital signature, if any, will remain on the page, but
-it will no longer be a signature field. See also
---remove-restrictions.
+This may be combined with --decrypt to allow free editing of
+previously signed/encrypted files. This option invalidates and
+disables any digital signatures but leaves their visual
+appearances intact.
)");
ap.addOptionHelp("--copy-encryption", "transformation", "copy another file's encryption details", R"(--copy-encryption=file
@@ -173,14 +168,14 @@ Copy encryption details from the specified file instead of
preserving the input file's encryption. Use --encryption-file-password
to specify the encryption file's password.
)");
-}
-static void add_help_3(QPDFArgParser& ap)
-{
ap.addOptionHelp("--encryption-file-password", "transformation", "supply password for --copy-encryption", R"(--encryption-file-password=password
If the file named in --copy-encryption requires a password, use
this option to supply the password.
)");
+}
+static void add_help_3(QPDFArgParser& ap)
+{
ap.addOptionHelp("--qdf", "transformation", "enable viewing PDF code in a text editor", R"(Create a PDF file suitable for viewing in a text editor and even
editing. This is for editing the PDF code, not the page contents.
All streams that can be uncompressed are uncompressed, and
@@ -290,9 +285,6 @@ Force the output PDF file's PDF version header to be the specified
value, even if the file uses features that may not be available
in that version.
)");
-}
-static void add_help_4(QPDFArgParser& ap)
-{
ap.addHelpTopic("page-ranges", "page range syntax", R"(A full description of the page range syntax, with examples, can be
found in the manual. Summary:
@@ -306,6 +298,9 @@ resulting set of pages, where :odd starts with the first page and
:even starts with the second page. These are odd and even pages
from the resulting set, not based on the original page numbers.
)");
+}
+static void add_help_4(QPDFArgParser& ap)
+{
ap.addHelpTopic("modification", "change parts of the PDF", R"(Modification options make systematic changes to certain parts of
the PDF, causing the PDF to render differently from the original.
)");
@@ -481,13 +476,13 @@ ap.addOptionHelp("--user-password", "encryption", "specify user password", R"(--
Set the user password of the encrypted file.
)");
-}
-static void add_help_5(QPDFArgParser& ap)
-{
ap.addOptionHelp("--owner-password", "encryption", "specify owner password", R"(--owner-password=owner-password
Set the owner password of the encrypted file.
)");
+}
+static void add_help_5(QPDFArgParser& ap)
+{
ap.addOptionHelp("--bits", "encryption", "specify encryption key length", R"(--bits={48|128|256}
Specify the encryption key length. For best security, always use
@@ -659,15 +654,15 @@ the destination pages. See qpdf --help=page-ranges for help
with the page range syntax. The page range may be omitted
if --repeat is used.
)");
-}
-static void add_help_6(QPDFArgParser& ap)
-{
ap.addOptionHelp("--repeat", "overlay-underlay", "overlay/underlay pages to repeat", R"(--repeat=page-range
Specify pages from the overlay/underlay that are repeated after
"from" pages have been exhausted. See qpdf --help=page-ranges
for help with the page range syntax.
)");
+}
+static void add_help_6(QPDFArgParser& ap)
+{
ap.addHelpTopic("attachments", "work with embedded files", R"(It is possible to list, add, or delete embedded files (also known
as attachments) and to copy attachments from other files. See help
on individual options for details. Run qpdf --help=add-attachment
@@ -776,9 +771,6 @@ ap.addOptionHelp("--requires-password", "inspection", "silently test a file's pa
2: the file is not encrypted
3: the file is encrypted, and correct password (if any) has been supplied
)");
-}
-static void add_help_7(QPDFArgParser& ap)
-{
ap.addOptionHelp("--check", "inspection", "partially check whether PDF is valid", R"(Check the structure of the PDF file as well as a number of other
aspects of the file, and write information about the file to
standard output. Note that qpdf does not perform any validation
@@ -786,6 +778,9 @@ of the actual PDF page content or semantic correctness of the
PDF file. It merely checks that the PDF file is syntactically
valid. See also qpdf --help=exit-status.
)");
+}
+static void add_help_7(QPDFArgParser& ap)
+{
ap.addOptionHelp("--show-encryption", "inspection", "information about encrypted files", R"(Show document encryption parameters. Also show the document's
user password if the owner password is given and the file was
encrypted using older encryption formats that allow user
@@ -866,9 +861,6 @@ This option is repeatable. If given, only specified objects will
be shown in the "objects" key of the JSON output. Otherwise, all
objects will be shown.
)");
-}
-static void add_help_8(QPDFArgParser& ap)
-{
ap.addOptionHelp("--json-stream-data", "json", "how to handle streams in json output", R"(--json-stream-data={none|inline|file}
When used with --json, this option controls whether streams in
@@ -880,6 +872,9 @@ object number. The prefix can be overridden with
when --json-output is specified, in which case the default is
"inline".
)");
+}
+static void add_help_8(QPDFArgParser& ap)
+{
ap.addOptionHelp("--json-stream-prefix", "json", "prefix for json stream data files", R"(--json-stream-prefix=file-prefix
When used with --json-stream-data=file, --json-stream-data=file-prefix
diff --git a/libqpdf/qpdf/auto_job_init.hh b/libqpdf/qpdf/auto_job_init.hh
index 5aa280d1..23b55c7f 100644
--- a/libqpdf/qpdf/auto_job_init.hh
+++ b/libqpdf/qpdf/auto_job_init.hh
@@ -43,7 +43,6 @@ this->ap.addBare("coalesce-contents", [this](){c_main->coalesceContents();});
this->ap.addBare("copy-attachments-from", b(&ArgParser::argCopyAttachmentsFrom));
this->ap.addBare("decrypt", [this](){c_main->decrypt();});
this->ap.addBare("deterministic-id", [this](){c_main->deterministicId();});
-this->ap.addBare("disable-signatures", [this](){c_main->disableSignatures();});
this->ap.addBare("empty", b(&ArgParser::argEmpty));
this->ap.addBare("encrypt", b(&ArgParser::argEncrypt));
this->ap.addBare("externalize-inline-images", [this](){c_main->externalizeInlineImages();});
diff --git a/libqpdf/qpdf/auto_job_json_init.hh b/libqpdf/qpdf/auto_job_json_init.hh
index bce96593..135a5159 100644
--- a/libqpdf/qpdf/auto_job_json_init.hh
+++ b/libqpdf/qpdf/auto_job_json_init.hh
@@ -71,9 +71,6 @@ popHandler(); // key: decrypt
pushKey("deterministicId");
addBare([this]() { c_main->deterministicId(); });
popHandler(); // key: deterministicId
-pushKey("disableSignatures");
-addBare([this]() { c_main->disableSignatures(); });
-popHandler(); // key: disableSignatures
pushKey("staticAesIv");
addBare([this]() { c_main->staticAesIv(); });
popHandler(); // key: staticAesIv
diff --git a/libqpdf/qpdf/auto_job_schema.hh b/libqpdf/qpdf/auto_job_schema.hh
index bd238aca..84f4cd4a 100644
--- a/libqpdf/qpdf/auto_job_schema.hh
+++ b/libqpdf/qpdf/auto_job_schema.hh
@@ -16,7 +16,6 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
"decodeLevel": "control which streams to uncompress",
"decrypt": "remove encryption from input file",
"deterministicId": "generate ID deterministically",
- "disableSignatures": "disable digital signature fields",
"staticAesIv": "use a fixed AES vector",
"staticId": "use a fixed document ID",
"noOriginalObjectIds": "omit original object IDs in qdf",