Overworked mailbox

This commit is contained in:
Torsten Schulz
2023-10-16 19:12:08 +02:00
parent f70d6d1224
commit c97239f1fc
3 changed files with 40 additions and 13 deletions

View File

@@ -508,4 +508,29 @@ class Renderer {
return htmlspecialchars($name . ' (' . $row['description'] . ')');
}
function decodeSubject($subject) {
return $subject;
// Match the encoding and encoded string using a regular expression
preg_match_all('/=\?([^?]+)\?([QB])\?([^?]+)\?=/i', $subject, $matches, PREG_SET_ORDER);
$decoded = '';
foreach ($matches as $match) {
$encoding = $match[1];
$type = $match[2];
$encoded_string = $match[3];
if ($type == 'Q') {
$decoded_part = quoted_printable_decode($encoded_string);
} elseif ($type == 'B') {
$decoded_part = base64_decode($encoded_string);
}
var_dump($match);
if (strtolower($encoding) != 'utf-8') {
$decoded_part = iconv($encoding, 'UTF-8', $decoded_part);
}
$decoded .= str_replace('_', ' ', $decoded_part);
}
return $decoded;
}
}