diff --git a/pyhanko/sign/diff_analysis/rules/form_field_rules.py b/pyhanko/sign/diff_analysis/rules/form_field_rules.py index 4d0e798f..1e98a153 100644 --- a/pyhanko/sign/diff_analysis/rules/form_field_rules.py +++ b/pyhanko/sign/diff_analysis/rules/form_field_rules.py @@ -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: diff --git a/pyhanko_tests/data/pdf/minimal-signed-twice-no-sig-type.pdf b/pyhanko_tests/data/pdf/minimal-signed-twice-no-sig-type.pdf new file mode 100644 index 00000000..4da46f54 Binary files /dev/null and b/pyhanko_tests/data/pdf/minimal-signed-twice-no-sig-type.pdf differ diff --git a/pyhanko_tests/test_diff_analysis.py b/pyhanko_tests/test_diff_analysis.py index 19581fe1..d8f94d6b 100644 --- a/pyhanko_tests/test_diff_analysis.py +++ b/pyhanko_tests/test_diff_analysis.py @@ -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 + )