NobGit
public nobgit read

NobMail

Based on mailcow: dockerized

Languages

Repository composition by tracked source files.

PHP
PHP 49% JavaScript 35% HTML 9% CSS 4% Shell 2% Python 1% Lua 0% Perl 0% Ruby 0% SCSS 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git

Commit

[Web] Fall back to raw content when mail parsing fails, fixes #1892

b8fe3f5f
AndrĂ© <[email protected]> 8 years ago
data/web/inc/ajax/qitem_details.php | 7 +++++++
 1 file changed, 7 insertions(+)

Diff

diff --git a/data/web/inc/ajax/qitem_details.php b/data/web/inc/ajax/qitem_details.php
index 801fd3d0..fedca73b 100644
--- a/data/web/inc/ajax/qitem_details.php
+++ b/data/web/inc/ajax/qitem_details.php
@@ -40,6 +40,13 @@ if (!empty($_GET['id']) && ctype_alnum($_GET['id'])) {
     $data['text_plain'] = $mail_parser->getMessageBody('text');
     // Get html content and convert to text
     $data['text_html'] = $html2text->convert($mail_parser->getMessageBody('html'));
+    if (empty($data['text_plain']) && empty($data['text_html'])) {
+      // Failed to parse content, try raw
+      $text = trim(substr($mailc['msg'], strpos($mailc['msg'], "\r\n\r\n") + 1));
+      // Only return html->text
+      $data['text_plain'] = 'Parser failed, assuming HTML';
+      $data['text_html'] = $html2text->convert($text);
+    }
     (empty($data['text_plain'])) ? $data['text_plain'] = '-' : null;
     // Get subject
     $data['subject'] = $mail_parser->getHeader('subject');