diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-09-06 17:18:56 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-09-06 18:45:12 +0200 |
commit | 94c79bb8f65e2a13c7bbe03437d2c8354068acb6 (patch) | |
tree | 37c0f320bab812ae292899fc1556f9f292b8ecef /qpdf | |
parent | 7e07897106e0b0bb4d723d4fb5660a24fcc7a148 (diff) | |
download | qpdf-94c79bb8f65e2a13c7bbe03437d2c8354068acb6.tar.zst |
Support --show-encryption without a valid password (fixes #598)
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qtest/encryption.test | 8 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/invalid-password-encrypt.out | 13 | ||||
-rw-r--r-- | qpdf/qtest/unicode-password.test | 4 |
3 files changed, 23 insertions, 2 deletions
diff --git a/qpdf/qtest/encryption.test b/qpdf/qtest/encryption.test index 27974a82..672eb995 100644 --- a/qpdf/qtest/encryption.test +++ b/qpdf/qtest/encryption.test @@ -112,7 +112,7 @@ my @encrypted_files = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ); -$n_tests += 8 + (2 * (@encrypted_files)) + (7 * (@encrypted_files - 6)) + 9; +$n_tests += 8 + (2 * (@encrypted_files)) + (7 * (@encrypted_files - 6)) + 10; $td->runtest("encrypted file", {$td->COMMAND => "test_driver 2 encrypted-with-images.pdf"}, @@ -365,6 +365,12 @@ $td->runtest("C API: invalid password", "qpdf-ctest 2 enc-R2,V1,U=view,O=view.pdf '' a.qdf"}, {$td->FILE => "c-invalid-password.out", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); +$td->runtest("show-encryption works invalid password", + {$td->COMMAND => "qpdf --show-encryption --password=quack" . + " enc-R2,V1,U=view,O=view.pdf"}, + {$td->FILE => "invalid-password-encrypt.out", + $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); my @cenc = ( [11, 'hybrid-xref.pdf', "''", 'r2', "", ""], diff --git a/qpdf/qtest/qpdf/invalid-password-encrypt.out b/qpdf/qtest/qpdf/invalid-password-encrypt.out new file mode 100644 index 00000000..6e97b379 --- /dev/null +++ b/qpdf/qtest/qpdf/invalid-password-encrypt.out @@ -0,0 +1,13 @@ +Incorrect password supplied +R = 2 +P = -64 +User password = +extract for accessibility: not allowed +extract for any purpose: not allowed +print low resolution: not allowed +print high resolution: not allowed +modify document assembly: not allowed +modify forms: not allowed +modify annotations: not allowed +modify other: not allowed +modify anything: not allowed diff --git a/qpdf/qtest/unicode-password.test b/qpdf/qtest/unicode-password.test index eb78de42..db0c8bf8 100644 --- a/qpdf/qtest/unicode-password.test +++ b/qpdf/qtest/unicode-password.test @@ -147,9 +147,11 @@ foreach my $d (@unicode_pw_cases) } my $r_output = ""; $r_output .= "trying other\n" if $tried_others; + my $arg = "--show-encryption"; if ($xfail) { $r_output .= "qpdf: a.pdf: invalid password\n"; + $arg = "--check"; } else { @@ -162,7 +164,7 @@ foreach my $d (@unicode_pw_cases) $r_xargs .= $strict ? ' --suppress-password-recovery' : ''; $td->runtest("decrypt $pw, $r_encoding, strict=$strict", {$td->COMMAND => - "qpdf --show-encryption --verbose" . + "qpdf $arg --verbose" . " $r_xargs a.pdf \@$r_pfile", $td->FILTER => "perl show-unicode-encryption.pl"}, {$td->STRING => "$r_output", |