Hardened against XML parsing failures in metadata reading

This commit is contained in:
John Whitington 2014-10-24 11:43:37 +01:00
parent 19b9d56c5a
commit 898776ee73
1 changed files with 15 additions and 12 deletions

27
cpdf.ml
View File

@ -2932,18 +2932,21 @@ let output_xmp_info encoding pdf =
match get_metadata pdf with match get_metadata pdf with
None -> () None -> ()
| Some metadata -> | Some metadata ->
let dtd, tree = xmltree_of_bytes metadata in try
print_out tree "XMP pdf:Keywords" adobe "Keywords"; let dtd, tree = xmltree_of_bytes metadata in
print_out tree "XMP pdf:PDFVersion" adobe "PDFVersion"; print_out tree "XMP pdf:Keywords" adobe "Keywords";
print_out tree "XMP pdf:Producer" adobe "Producer"; print_out tree "XMP pdf:PDFVersion" adobe "PDFVersion";
print_out tree "XMP pdf:Trapped" adobe "Trapped"; print_out tree "XMP pdf:Producer" adobe "Producer";
print_out tree "XMP xmp:CreateDate" xmp "CreateDate"; print_out tree "XMP pdf:Trapped" adobe "Trapped";
print_out tree "XMP xmp:CreatorTool" xmp "CreatorTool"; print_out tree "XMP xmp:CreateDate" xmp "CreateDate";
print_out tree "XMP xmp:MetadataDate" xmp "MetadataDate"; print_out tree "XMP xmp:CreatorTool" xmp "CreatorTool";
print_out tree "XMP xmp:ModifyDate" xmp "ModifyDate"; print_out tree "XMP xmp:MetadataDate" xmp "MetadataDate";
print_out tree "XMP dc:title" dc "title"; print_out tree "XMP xmp:ModifyDate" xmp "ModifyDate";
print_out tree "XMP dc:creator" dc "creator"; print_out tree "XMP dc:title" dc "title";
print_out tree "XMP dc:subject" dc "subject" print_out tree "XMP dc:creator" dc "creator";
print_out tree "XMP dc:subject" dc "subject"
with
_ -> ()
(* \section{Blacken text} *) (* \section{Blacken text} *)