Skip to content

Commit

Permalink
Merge pull request #356 from cip91sk/no_type
Browse files Browse the repository at this point in the history
handle fields with no /Type set
  • Loading branch information
MatthiasValvekens authored Dec 13, 2023
2 parents 5f9ac0f + 8e4185f commit 642be7f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyhanko/sign/diff_analysis/rules/form_field_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,11 @@ def check_form_field(
# /DocTimeStamps added for LTA validation purposes shouldn't have
# an appearance (as per the recommendation in ISO 32000-2, which we
# enforce as a rigid rule here)
if sig_obj.raw_get('/Type') == '/DocTimeStamp' and not visible:
if (
'/Type' in sig_obj
and sig_obj.raw_get('/Type') == '/DocTimeStamp'
and not visible
):
sig_whitelist = ModificationLevel.LTA_UPDATES
valid_when_locked = True
else:
Expand Down
Binary file not shown.
12 changes: 12 additions & 0 deletions pyhanko_tests/test_diff_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2656,3 +2656,15 @@ def test_cant_descend_into_non_container():

with pytest.raises(PdfReadError, match='Anchor'):
root_rel.descend('/Blah')


def test_signature_without_type_is_form_filling():
fname = f"{PDF_DATA_DIR}/minimal-signed-twice-no-sig-type.pdf"
with open(fname, 'rb') as inf:
r = PdfFileReader(inf)
s = r.embedded_signatures[0]
s.compute_integrity_info(DEFAULT_DIFF_POLICY)
assert s.field_name == 'Sig1'
assert (
s.diff_result.modification_level == ModificationLevel.FORM_FILLING
)

0 comments on commit 642be7f

Please sign in to comment.