mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	Compressed and Encrypted metadata now dealt with ok
This commit is contained in:
		
							
								
								
									
										2
									
								
								cpdf.ml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								cpdf.ml
									
									
									
									
									
								
							| @@ -1285,7 +1285,7 @@ let get_metadata pdf = | ||||
|   | Some root -> | ||||
|       match Pdf.lookup_direct pdf "/Metadata" root with | ||||
|       | Some ((Pdf.Stream _) as s) -> | ||||
|           Pdf.getstream s; | ||||
|           Pdfcodec.decode_pdfstream pdf s; | ||||
|           begin match s with | ||||
|           | Pdf.Stream {contents = (_, Pdf.Got data)} -> Some data  | ||||
|           | _ -> assert false | ||||
|   | ||||
| @@ -545,11 +545,13 @@ let rec decrypt_if_necessary (_, _, _, user_pw, owner_pw) op pdf = | ||||
|   end; | ||||
|   if not (Pdfcrypt.is_encrypted pdf) then pdf else | ||||
|     match Pdfcrypt.decrypt_pdf_owner owner_pw pdf with | ||||
|     | Some pdf -> pdf | ||||
|     | Some pdf -> | ||||
|         Printf.printf "Managed to decrypt with owner password"; pdf | ||||
|     | _ -> | ||||
|       Printf.printf "Couldn't decrypt with owner password %s\n" owner_pw; | ||||
|       match Pdfcrypt.decrypt_pdf user_pw pdf with | ||||
|       | Some pdf, permissions -> | ||||
|           Printf.printf "Managed to decrypt with user password\n"; | ||||
|           if operation_allowed permissions op | ||||
|             then pdf | ||||
|             else soft_error "User password cannot give permission for this operation" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user