Commit 7b0cc44a authored by Alexander's avatar Alexander Committed by Johannes

fix json errors in mailbox view

parent 1b747728
Pipeline #108134905 passed with stages
in 14 minutes and 51 seconds
......@@ -67,7 +67,7 @@
- Redesign for chatbox and messages page !1265 @chriswalg
- Center basket map on Germany if logged out !1249 #740 @alex.simm
- Show correct from/to information in mailboxes !1264 !1239 #603 @alex.simm
- Fix adding members to mailboxes by orga !1255 #677 @alex.simm
- Fix adding members to mailboxes by orga !1255 !1302 #677 @alex.simm
- Fix missing translations for MenuBasketsEntry. !1271 #761 @ctwx_ok
- disable delete account buttons for non-orga users !1279 @Caluera
- repaired link to profile in the very first pinwall post #512 !1281 @Caluera
......
......@@ -114,11 +114,25 @@ class MailboxView extends View
}
}
/**
* Removes leading and trailing quotation marks and replaces escaped quotation marks.
*/
private function fixQuotation(string $json): string
{
$trimmed = trim($json, '"');
return str_replace('\"', '"', $trimmed);
}
public function listMessages(array $messages, int $folder, string $currentMailboxName)
{
$out = '';
foreach ($messages as $m) {
// fix wrong quotation that can occur in some data sets
$m['from'] = $this->fixQuotation($m['from']);
$m['to'] = $this->fixQuotation($m['to']);
// create from/to text depending on the folder
$fromToAddresses = [];
switch ($folder) {
......@@ -139,10 +153,17 @@ class MailboxView extends View
}
break;
}
$mappedAddresses = array_map(function ($a) {
return $this->createMailAddressString($a);
}, array_filter($fromToAddresses));
$fromToText = implode(', ', $mappedAddresses);
// safety check: if json_decode fails it might return null or a string
if (!is_null($fromToAddresses) && is_array($fromToAddresses)) {
$mappedAddresses = array_map(function ($a) {
return $this->createMailAddressString($a);
}, array_filter($fromToAddresses));
$fromToText = implode(', ', $mappedAddresses);
} else {
$fromToText = '';
}
$attach_class = 'none';
if (!empty($m['attach'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment