Skip to content

Commit 9d90854

Browse files
committed
fix(backend): deal with mixed-case header names
1 parent 7dc410b commit 9d90854

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

modules/imap/output_modules.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,17 @@ protected function output() {
193193
if (!array_key_exists('subject', lc_headers($headers)) || !trim(lc_headers($headers)['subject'])) {
194194
$headers['subject'] = $this->trans('[No Subject]');
195195
}
196-
196+
197197
// Start Bootstrap container
198198
$txt .= '<div class="container-fluid p-0 ml-0 border-bottom border-secondary-subtle text-muted">';
199-
199+
200200
foreach ($small_headers as $fld) {
201201
foreach ($headers as $name => $value) {
202202
if ($fld == mb_strtolower($name)) {
203203
if ($fld == 'subject') {
204204
$txt .= '<div class="row g-0 py-0 py-sm-1 small_header d-flex">';
205205
$txt .= '<div class="col-12">';
206-
if (isset($headers['Flags']) && mb_stristr($headers['Flags'], 'flagged')) {
206+
if (array_key_exists('flags', lc_headers($headers)) && mb_stristr(lc_headers($headers)['flags'], 'flagged')) {
207207
$txt .= '<i class="bi bi-star-half account_icon"></i> ';
208208
}
209209
$txt .= '<span class="fs-5 fw-normal text-dark js-header_subject">' . $this->html_safe($value) . '</span>';
@@ -271,10 +271,10 @@ protected function output() {
271271
$txt .= '</div></div></div></div></div>';
272272
}
273273
elseif ($fld == 'reply-to') {
274-
$from = addr_parse($headers['From']);
274+
$from = addr_parse(lc_headers($headers)['from'] ?? '');
275275
$replyEmails = array_map(function ($addr) {
276276
return $addr['email'];
277-
}, process_address_fld($headers['Reply-To']));
277+
}, process_address_fld(lc_headers($headers)['reply-to'] ?? ''));
278278

279279
if (count($replyEmails) === 1 && ($replyEmails[0] === $from['email'])) {
280280
$txt .= '<div class="row g-0 py-1 long_header">';
@@ -307,7 +307,7 @@ protected function output() {
307307
}
308308
}
309309
}
310-
$is_draft = isset($headers['Flags']) && mb_stristr($headers['Flags'], 'draft');
310+
$is_draft = array_key_exists('flags', lc_headers($headers)) && mb_stristr(lc_headers($headers)['flags'], 'draft');
311311
if($is_draft) {
312312
$txt .= '<div class="row g-0 py-2"><div class="col-12 text-center text-md-start"><a class="btn btn-primary" href="?page=compose'.$reply_args.'&imap_draft=1"><i class="bi bi-pencil"></i> '.$this->trans('Edit Draft').'</a></div></div>';
313313
}
@@ -328,11 +328,11 @@ protected function output() {
328328
}
329329
}
330330
}
331-
331+
332332
if ($this->get('list_headers')) {
333333
$txt .= format_list_headers($this);
334334
}
335-
335+
336336
$lc_headers = lc_headers($headers);
337337
if (array_key_exists('to', $lc_headers)) {
338338
$addr_list = process_address_fld($lc_headers['to']);
@@ -362,9 +362,9 @@ protected function output() {
362362
$txt .= '<a href="#" class="hlink all_headers text-decoration-none btn btn-sm btn-outline-secondary">'.$this->trans('All headers').'</a>';
363363
$txt .= '<a class="hlink small_headers text-decoration-none btn btn-sm btn-outline-secondary" href="#">'.$this->trans('Small headers').'</a>';
364364
$txt .= '</div>';
365-
365+
366366
$txt .= '<div class="d-flex flex-wrap gap-2">';
367-
if (!isset($headers['Flags']) || !mb_stristr($headers['Flags'], 'draft')) {
367+
if (!array_key_exists('flags', $lc_headers) || !mb_stristr($lc_headers['flags'], 'draft')) {
368368
$txt .= '<a class="reply_link hlink text-decoration-none btn btn-sm btn-outline-secondary" href="?page=compose&amp;reply=1'.$reply_args.'">'.$this->trans('Reply').'</a>';
369369
if ($size > 1) {
370370
$txt .= '<a class="reply_all_link hlink text-decoration-none btn btn-sm btn-outline-secondary" href="?page=compose&amp;reply_all=1'.$reply_args.'">'.$this->trans('Reply-all').'</a>';
@@ -373,7 +373,7 @@ protected function output() {
373373
}
374374
$txt .= forward_dropdown($this, $reply_args);
375375
}
376-
if (isset($headers['Flags']) && mb_stristr($headers['Flags'], 'flagged')) {
376+
if (array_key_exists('flags', $lc_headers) && mb_stristr($lc_headers['flags'], 'flagged')) {
377377
$txt .= '<a id="flag_msg" class="flagged_link hlink text-decoration-none btn btn-sm btn-outline-secondary hide" data-state="unflagged" href="#">'.$this->trans('Flag').'</a>';
378378
$txt .= '<a id="unflag_msg" class="unflagged_link hlink text-decoration-none btn btn-sm btn-outline-secondary" data-state="flagged" href="#">'.$this->trans('Unflag').'</a>';
379379
} else {
@@ -388,17 +388,17 @@ protected function output() {
388388
if (!$this->get('is_archive_folder')) {
389389
$txt .= '<a class="archive_link hlink text-decoration-none btn btn-sm btn-outline-secondary" id="archive_message" href="#">'.$this->trans('Archive').'</a>';
390390
}
391-
391+
392392
if($this->get('tags')){
393393
$txt .= tags_dropdown($this, $headers);
394394
}
395-
if (isset($headers['X-Schedule'])) {
395+
if (isset($lc_headers['x-schedule'])) {
396396
$txt .= schedule_dropdown($this, true);
397397
}
398398

399399
$settings = $this->get('user_settings', array());
400400
if(array_key_exists('enable_snooze_setting', $settings) && $settings['enable_snooze_setting']) {
401-
$txt .= snooze_dropdown($this, isset($headers['X-Snoozed']));
401+
$txt .= snooze_dropdown($this, isset($lc_headers['x-snoozed']));
402402
}
403403
if ($this->get('sieve_filters_enabled') && !$is_draft) {
404404
$server_id = $this->get('msg_server_id');
@@ -407,7 +407,7 @@ protected function output() {
407407
$user_config = $this->get('user_config');
408408
$contact_list = $user_config->get('contacts', []);
409409
$existing_emails = array_column($contact_list, 'email_address');
410-
$sender = addr_parse($headers['From'])['email'];
410+
$sender = addr_parse($lc_headers['from'] ?? '')['email'];
411411
$domain = '*@'.get_domain($sender);
412412
$blocked_senders = get_blocked_senders_array($imap_server, $this->get('site_config'), $this->get('user_config'));
413413
$sender_blocked = in_array($sender, $blocked_senders);
@@ -742,7 +742,7 @@ protected function output() {
742742
}
743743
$res .= '</tr>';
744744
}
745-
}
745+
}
746746
return $res;
747747
}
748748
}
@@ -1299,7 +1299,7 @@ protected function output() {
12991299
if (!$enable_snooze) {
13001300
return;
13011301
}
1302-
1302+
13031303
$parts = explode('_', $this->get('list_path'));
13041304
$unsnooze = $parts[0] == 'imap' && hex2bin($parts[2]) == 'Snoozed';
13051305
$res = snooze_dropdown($this, $unsnooze);

0 commit comments

Comments
 (0)