Gracefully handle the is_aes check without throwing errors #376
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commit 9f22915 introduces a regression in 0.35 compared to 0.34 when decrypting a PDF document that does not use AES. Instead of decrypting the document, it throws an error that the CF dictionary is missing. Consequently, this prevents the document from being decrypted.
To remedy this, this pull request eliminates all uses of
?
in theis_aes
check to gracefully determine if the PDF document uses AES or not. It then proceeds to decrypt it accordingly.Instead of using
?
, we carefully convert allResult<T, E>
types intoOption<T>
using.ok()
in combination with.map()
and.flatten()
to walk through the series of dictionaries. Then at the final step we simply compare if thecfm
is equal tob"AESV2"
. If any of the steps fails, we would getNone
, in which case we default tois_aes = false
(rather than throwing an error).