mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Implement --remove-restrictions (fixes #833)
This commit is contained in:
parent
fe11f13d63
commit
1308c45090
@ -1,3 +1,8 @@
|
||||
2023-01-28 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* New option --remove-restrictions removes security restrictions
|
||||
from digitally signed files. Fixes #833.
|
||||
|
||||
2023-01-09 Jay Berkenbilt <ejb@ql.org>
|
||||
|
||||
* Bug fix: flatten annotations should handle a page with no
|
||||
|
@ -685,6 +685,10 @@ class QPDF
|
||||
// this file
|
||||
QPDF_DLL
|
||||
std::string getEncryptionKey() const;
|
||||
// Remove security restrictions associated with digitally signed
|
||||
// files.
|
||||
QPDF_DLL
|
||||
void removeSecurityRestrictions();
|
||||
|
||||
// Linearization support
|
||||
|
||||
|
@ -2777,3 +2777,14 @@ QPDF::everPushedInheritedAttributesToPages() const
|
||||
{
|
||||
return this->m->ever_pushed_inherited_attributes_to_pages;
|
||||
}
|
||||
|
||||
void
|
||||
QPDF::removeSecurityRestrictions()
|
||||
{
|
||||
auto root = getRoot();
|
||||
root.removeKey("/Perms");
|
||||
auto acroform = root.getKey("/AcroForm");
|
||||
if (acroform.isDictionary() && acroform.hasKey("/SigFlags")) {
|
||||
acroform.replaceKey("/SigFlags", QPDFObjectHandle::newInteger(0));
|
||||
}
|
||||
}
|
||||
|
@ -2333,6 +2333,9 @@ QPDFJob::handleTransformations(QPDF& pdf)
|
||||
afdh = std::make_shared<QPDFAcroFormDocumentHelper>(pdf);
|
||||
}
|
||||
};
|
||||
if (m->remove_restrictions) {
|
||||
pdf.removeSecurityRestrictions();
|
||||
}
|
||||
if (m->externalize_inline_images ||
|
||||
(m->optimize_images && (!m->keep_inline_images))) {
|
||||
for (auto& ph: dh.getAllPages()) {
|
||||
|
@ -8,6 +8,17 @@ For a detailed list of changes, please see the file
|
||||
|
||||
.. x.y.z: not yet released
|
||||
|
||||
11.3.0: not yet released
|
||||
- CLI Enhancements
|
||||
|
||||
- New option :qpdf:ref:`--remove-restrictions` removes security
|
||||
restrictions from digitally signed files.
|
||||
|
||||
- Library enhancements
|
||||
|
||||
- New method ``QPDF::removeSecurityRestrictions`` removes security
|
||||
restrictions from digitally signed files.
|
||||
|
||||
11.2.0: November 20, 2022
|
||||
- Build changes
|
||||
|
||||
|
BIN
qpdf/qtest/qpdf/minimal-signed-restricted.pdf
Normal file
BIN
qpdf/qtest/qpdf/minimal-signed-restricted.pdf
Normal file
Binary file not shown.
2324
qpdf/qtest/qpdf/minimal-signed-restrictions-removed.pdf
Normal file
2324
qpdf/qtest/qpdf/minimal-signed-restrictions-removed.pdf
Normal file
File diff suppressed because one or more lines are too long
@ -128,5 +128,16 @@ foreach my $i (qw(40 128 256))
|
||||
$td->EXIT_STATUS => 0});
|
||||
}
|
||||
|
||||
$n_tests += 2;
|
||||
$td->runtest("remove security restrictions",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --qdf --no-original-object-ids --static-id" .
|
||||
" --remove-restrictions minimal-signed-restricted.pdf a.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("checkout output (remove restrictions)",
|
||||
{$td->FILE => "a.pdf"},
|
||||
{$td->FILE => "minimal-signed-restrictions-removed.pdf"});
|
||||
|
||||
cleanup();
|
||||
$td->report($n_tests);
|
||||
|
Loading…
Reference in New Issue
Block a user