Skip to content

Commit b1e15dc

Browse files
committed
Update script.php
1 parent 13043a1 commit b1e15dc

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • public/demos/1-Core/analyze/check-for-digital-signatures

public/demos/1-Core/analyze/check-for-digital-signatures/script.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
$signatureFieldFound = true;
4141

4242
$v = DictionaryHelper::resolveAttribute($fieldData, 'V');
43-
if (!$v || !$v->ensure() instanceof PdfDictionary) {
43+
if (!$v instanceof PdfDictionary) {
4444
echo ' But not digital signed.<br /><br />';
4545
continue;
4646
}
4747

4848
echo ' Including a digital signature.<br />';
4949

5050
// This is the signature value
51-
$signatureData = $v->ensure()->getValue('Contents')->ensure()->getValue();
51+
$signatureData = PdfHexString::ensureType(DictionaryHelper::getValue($v, 'Contents'))->getValue();
5252
$signatureData = rtrim($signatureData, "\0");
5353

5454
echo '<a href="https://lapo.it/asn1js/#' . PdfHexString::str2hex($signatureData) . '" ' .
@@ -58,14 +58,14 @@
5858

5959
echo '<br />';
6060

61-
$value = $v->ensure();
6261
$signatureProperties = [];
6362
foreach (['Name', 'Location', 'ContactInfo', 'Reason', 'M'] as $property) {
64-
if (!$value->offsetExists($property)) {
63+
$value = DictionaryHelper::getValue($v, $property);
64+
if ($value === null) {
6565
continue;
6666
}
6767

68-
$propertyValue = $value->getValue($property)->ensure()->getValue();
68+
$propertyValue = $value->getValue();
6969
if ($property === 'M') {
7070
$propertyValue = Date::stringToDateTime($propertyValue);
7171
} else {

0 commit comments

Comments
 (0)