From 4e102310be1be33630442926c9710b577b5c1236 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Fri, 27 Sep 2024 03:26:40 -0700 Subject: [PATCH] Try to handle articles with no 'text/plain' and arts with no text at all. Also don't display current 'part' as attachement if in current view. --- Rocksolid_Light/rocksolid/lib/message.inc.php | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/Rocksolid_Light/rocksolid/lib/message.inc.php b/Rocksolid_Light/rocksolid/lib/message.inc.php index 8bb5cc1..09fdf77 100644 --- a/Rocksolid_Light/rocksolid/lib/message.inc.php +++ b/Rocksolid_Light/rocksolid/lib/message.inc.php @@ -845,18 +845,27 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl return "blocked"; } } - if (($head->content_type[$attachment] == "text/plain") && ($attachment == 0)) { - // If we can't find the actual text in 'zero', check 'one' just in case + // If attachment=0 newsportal expects it to be plain text + if (($head->content_type[$attachment] == "text/plain") && ($attachment == 0)) { + // If we can't find the actual text in 'zero', look for it just in case if (trim($body) == '') { // There is no text in the text/plain body, it seems - if ($head->content_type[$attachment + 1] == "text/plain") { // There's another text/plain body. Lucky us! - $body = $article_data->body[$attachment + 1]; + $plaintext = false; + for ($o = 1; $o < count($head->content_type); $o++) { + if ($head->content_type[$o] == "text/plain") { + if (trim($article_data->body[$o]) != '') { + $plaintext = $o; // we found at least one text/plain + $body = $article_data->body[$o]; + break; + } + } + } + if ($plaintext === false) { + $notice = '

(message #' . $head->number . ' - no text found in message body)


'; } } - show_header($head, $group, $local_poster); echo $notice; - // X-Face if (($face = display_full_headers($head->number, $group, $head->name, $head->from, true)) && ($OVERRIDES['disable_xface'] != true)) { $pngfile = '../tmp/face-' . hash('ripemd160', $face); @@ -950,20 +959,31 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl } $type = explode('/', $head->content_type[$i]); if (trim($type[0]) == "image") { + if ($i > 2) { + echo ', '; + } echo '' . '' . $contype . ' '; } else { - echo '' . $contype . ' (' . $head->content_type[$i] . ')'; + if ($plaintext !== false && $plaintext != $i) { + if ($i > 2) { + echo ', '; + } + echo '' . $contype . ' (' . $head->content_type[$i] . ')'; + } } - if ($i < count($head->content_type) - 1) - echo ', '; } } echo ''; } else { - echo $body; + if ($attachment == 0) { + show_header($head, $group, $local_poster); + $notice = '

(message #' . $head->number . " - no 'text/plain' part found in this message)


"; + echo $notice; + } else { + echo $body; + } } } - echo ''; } function message_decrypt($key, $group, $id, $attachment = 0, $article_data = false, $maxlen = false)