Skip to content

Commit eab5212

Browse files
author
Sebastian Krätzig
committed
Fix PossiblyUndefinedIntArrayOffset
1 parent 0e6107d commit eab5212

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/PhpImap/Imap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ public static function open(
695695
array $params = []
696696
) {
697697
if (\preg_match("/^\{.*\}(.*)$/", $mailbox, $matches)) {
698-
$mailbox_name = $matches[1];
698+
$mailbox_name = $matches[1] ?? '';
699699

700700
if (!\mb_detect_encoding($mailbox_name, 'ASCII', true)) {
701701
$mailbox = static::encodeStringToUtf7Imap($mailbox);

src/PhpImap/Mailbox.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,20 +1127,20 @@ public function getMailHeader(int $mailId): IncomingMailHeader
11271127
$header->imapPath = $this->imapPath;
11281128
$header->mailboxFolder = $this->mailboxFolder;
11291129
$header->isDraft = (!isset($head->date)) ? true : false;
1130-
$header->mimeVersion = (\preg_match("/MIME-Version\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1131-
$header->xVirusScanned = (\preg_match("/X-Virus-Scanned\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1132-
$header->organization = (\preg_match("/Organization\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1133-
$header->contentType = (\preg_match("/Content-Type\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1134-
$header->xMailer = (\preg_match("/X-Mailer\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1135-
$header->contentLanguage = (\preg_match("/Content-Language\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1136-
$header->xSenderIp = (\preg_match("/X-Sender-IP\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1137-
$header->priority = (\preg_match("/Priority\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1138-
$header->importance = (\preg_match("/Importance\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1139-
$header->sensitivity = (\preg_match("/Sensitivity\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1140-
$header->autoSubmitted = (\preg_match("/Auto-Submitted\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1141-
$header->precedence = (\preg_match("/Precedence\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1142-
$header->failedRecipients = (\preg_match("/Failed-Recipients\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1143-
$header->xOriginalTo = (\preg_match("/X-Original-To\:(.*)/i", $headersRaw, $matches)) ? \trim($matches[1]) : '';
1130+
$header->mimeVersion = (\preg_match("/MIME-Version\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1131+
$header->xVirusScanned = (\preg_match("/X-Virus-Scanned\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1132+
$header->organization = (\preg_match("/Organization\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1133+
$header->contentType = (\preg_match("/Content-Type\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1134+
$header->xMailer = (\preg_match("/X-Mailer\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1135+
$header->contentLanguage = (\preg_match("/Content-Language\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1136+
$header->xSenderIp = (\preg_match("/X-Sender-IP\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1137+
$header->priority = (\preg_match("/Priority\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1138+
$header->importance = (\preg_match("/Importance\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1139+
$header->sensitivity = (\preg_match("/Sensitivity\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1140+
$header->autoSubmitted = (\preg_match("/Auto-Submitted\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1141+
$header->precedence = (\preg_match("/Precedence\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1142+
$header->failedRecipients = (\preg_match("/Failed-Recipients\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
1143+
$header->xOriginalTo = (\preg_match("/X-Original-To\:(.*)/i", $headersRaw, $matches)) ? (!isset($matches[1]) ?: \trim($matches[1])) : '';
11441144

11451145
if (isset($head->date) && !empty(\trim($head->date))) {
11461146
$header->date = self::parseDateTime($head->date);
@@ -1708,7 +1708,7 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
17081708
}
17091709
if (!empty($partStructure->dparameters)) {
17101710
foreach ($partStructure->dparameters as $param) {
1711-
$paramName = \strtolower(\preg_match('~^(.*?)\*~', $param->attribute, $matches) ? $matches[1] : $param->attribute);
1711+
$paramName = \strtolower(\preg_match('~^(.*?)\*~', $param->attribute, $matches) ? (!isset($matches[1]) ?: $matches[1]) : $param->attribute);
17121712
if (isset($params[$paramName])) {
17131713
$params[$paramName] .= $param->value;
17141714
} else {
@@ -1807,7 +1807,7 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
18071807
protected function decodeRFC2231(string $string): string
18081808
{
18091809
if (\preg_match("/^(.*?)'.*?'(.*?)$/", $string, $matches)) {
1810-
$data = $matches[2];
1810+
$data = isset($matches[2]) ? $matches[2] : '';
18111811
if ($this->isUrlEncoded($data)) {
18121812
$string = $this->decodeMimeStr(\urldecode($data));
18131813
}

0 commit comments

Comments
 (0)