MatthiasValvekens / pyHanko

pyHanko: sign and stamp PDF files
MIT License
460 stars 68 forks source link

handle fields with no /Type set #356

Closed cip91sk closed 7 months ago

cip91sk commented 7 months ago

Description of the changes

Prevents a KeyError bubbling up if the '/Type' key is not set in a field definition

Checklist

Please go over this checklist to increase the chances of your PR being worked on in a timely manner. Deviations are allowed with proper justification (see previous section).

For bug fixes (delete if not applicable)

Additional comments

While extracting signature info from files received from a third party, pyHanko failed on me with the KeyError Exception while trying to raw_get '/Type'. I apologise if I missed something in the PR, and while I'm here, thank you for your great work!

MatthiasValvekens commented 7 months ago

Hi @cip91sk, thanks for this bugfix! I've added a regression test. Will merge this when the CI workflows pass.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (5f9ac0f) 98.83% compared to head (8e4185f) 98.83%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #356 +/- ## ======================================= Coverage 98.83% 98.83% ======================================= Files 113 113 Lines 16289 16289 ======================================= Hits 16099 16099 Misses 190 190 ``` | [Flag](https://app.codecov.io/gh/MatthiasValvekens/pyHanko/pull/356/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matthias+Valvekens) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/MatthiasValvekens/pyHanko/pull/356/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matthias+Valvekens) | `98.83% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matthias+Valvekens#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.