Skip to content

Commit ad2a33d

Browse files
committed
Avoid PHP warnings about undefined indexes when sanitizing malformed PEMs
1 parent 783a119 commit ad2a33d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Library/KeyManagement/KeyConverter/KeyConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,9 @@ private static function sanitizePEM(string &$pem): void
399399
preg_match_all('#(-.*-)#', $pem, $matches, PREG_PATTERN_ORDER);
400400
$ciphertext = preg_replace('#-.*-|\r|\n| #', '', $pem);
401401

402-
$pem = $matches[0][0] . PHP_EOL;
402+
$pem = ($matches[0][0] ?? '') . PHP_EOL;
403403
$pem .= chunk_split($ciphertext ?? '', 64, PHP_EOL);
404-
$pem .= $matches[0][1] . PHP_EOL;
404+
$pem .= ($matches[0][1] ?? '') . PHP_EOL;
405405
}
406406

407407
/**

0 commit comments

Comments
 (0)