Skip to content

Commit 9f79f6c

Browse files
fix: prevent invalid return type
Signed-off-by: Christoph Wurst <[email protected]>
1 parent 178b080 commit 9f79f6c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/IMAP/ImapMessageFetcher.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,12 @@ private function decodeSubject(Horde_Imap_Client_Data_Envelope $envelope): strin
504504
if ($utf8 !== false) {
505505
return $utf8;
506506
}
507-
return iconv('UTF-8', 'UTF-8//IGNORE', $subject);
507+
$utf8Ignored = iconv('UTF-8', 'UTF-8//IGNORE', $subject);
508+
if ($utf8Ignored === false) {
509+
// Give up
510+
return $subject;
511+
}
512+
return $utf8Ignored;
508513
}
509514

510515
private function parseHeaders(Horde_Imap_Client_Data_Fetch $fetch): void {

lib/Service/Classification/PersistenceService.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,15 @@ private function getCached(string $id): ?array {
205205
}
206206

207207
$serializedData = json_decode($json);
208-
return array_map(base64_decode(...), $serializedData);
208+
$decodedData = array_map(base64_decode(...), $serializedData);
209+
foreach ($decodedData as $decoded) {
210+
if ($decoded === false) {
211+
// Decoding failed, abort
212+
return null;
213+
}
214+
}
215+
/** @var string[] $decodedData */
216+
return $decodedData;
209217
}
210218

211219
/**

0 commit comments

Comments
 (0)