mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-02-17 12:20:43 +01:00
Permissions for -combine-pages
This commit is contained in:
parent
c3683b3c0b
commit
29f663e85b
@ -586,22 +586,29 @@ let rec decrypt_if_necessary (_, _, _, user_pw, owner_pw, was_dec_with_owner) op
|
|||||||
| Some x -> Printf.printf "decrypt_if_necessary: op = %s\n" (string_of_op x)
|
| Some x -> Printf.printf "decrypt_if_necessary: op = %s\n" (string_of_op x)
|
||||||
end;
|
end;
|
||||||
if not (Pdfcrypt.is_encrypted pdf) then pdf else
|
if not (Pdfcrypt.is_encrypted pdf) then pdf else
|
||||||
match Pdfcrypt.decrypt_pdf_owner owner_pw pdf with
|
match op with Some (CombinePages _) ->
|
||||||
| Some pdf ->
|
(* This is a hack because we don't have support for recryption on combine
|
||||||
args.was_decrypted_with_owner <- true;
|
* pages. This is pervented by permissions above, but in the case that the
|
||||||
was_dec_with_owner := true;
|
* owner password is blank (e.g christmas_tree_lights.pdf), we would end
|
||||||
if args.debugcrypt then Printf.printf "Managed to decrypt with owner password\n";
|
* up here. *)
|
||||||
pdf
|
soft_error "Combine pages: both files must be unencrypted for this operation."
|
||||||
| _ ->
|
| _ ->
|
||||||
if args.debugcrypt then Printf.printf "Couldn't decrypt with owner password %s\n" owner_pw;
|
match Pdfcrypt.decrypt_pdf_owner owner_pw pdf with
|
||||||
match Pdfcrypt.decrypt_pdf user_pw pdf with
|
| Some pdf ->
|
||||||
| Some pdf, permissions ->
|
args.was_decrypted_with_owner <- true;
|
||||||
if args.debugcrypt then Printf.printf "Managed to decrypt with user password\n";
|
was_dec_with_owner := true;
|
||||||
if operation_allowed pdf permissions op
|
if args.debugcrypt then Printf.printf "Managed to decrypt with owner password\n";
|
||||||
then pdf
|
pdf
|
||||||
else soft_error "User password cannot give permission for this operation"
|
|
||||||
| _ ->
|
| _ ->
|
||||||
soft_error "Failed to decrypt file: wrong password?"
|
if args.debugcrypt then Printf.printf "Couldn't decrypt with owner password %s\n" owner_pw;
|
||||||
|
match Pdfcrypt.decrypt_pdf user_pw pdf with
|
||||||
|
| Some pdf, permissions ->
|
||||||
|
if args.debugcrypt then Printf.printf "Managed to decrypt with user password\n";
|
||||||
|
if operation_allowed pdf permissions op
|
||||||
|
then pdf
|
||||||
|
else soft_error "User password cannot give permission for this operation"
|
||||||
|
| _ ->
|
||||||
|
soft_error "Failed to decrypt file: wrong password?"
|
||||||
|
|
||||||
let nobble pdf =
|
let nobble pdf =
|
||||||
if not demo then pdf else
|
if not demo then pdf else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user