From 8f6b17e89439be9fd0cb9b80f1732d3264859294 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Tue, 17 Sep 2024 04:00:13 -0700 Subject: [PATCH 1/8] Make sure dot is at first char of line checking end of message in rslight-lib.php. --- Rocksolid_Light/rslight/scripts/rslight-lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rocksolid_Light/rslight/scripts/rslight-lib.php b/Rocksolid_Light/rslight/scripts/rslight-lib.php index 2160b46..3107726 100644 --- a/Rocksolid_Light/rslight/scripts/rslight-lib.php +++ b/Rocksolid_Light/rslight/scripts/rslight-lib.php @@ -93,7 +93,7 @@ function interact($msgsock, $use_crypto = false) $tempfilehandle = fopen($tempfilename, 'wb'); fwrite($msgsock, $msg, strlen($msg)); $buf = fgets($msgsock, 2048); - while (trim($buf) !== '.') { + while (rtrim($buf) !== '.') { fwrite($tempfilehandle, $buf); $buf = fgets($msgsock, 2048); } From 7b197a2612979616de6245860e7d5c9ec919fbe2 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Tue, 17 Sep 2024 04:00:42 -0700 Subject: [PATCH 2/8] Remove cookie check in checking logged in to avoid cookies disabled error. --- Rocksolid_Light/rocksolid/newsportal.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index cafc60e..46e2f1a 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1302,9 +1302,11 @@ function verify_logged_in($name) { $logged_in = false; $ip_pass = false; - if(!isset($_COOKIE['mail_name']) || trim($_COOKIE['mail_name'] == '')) { - return false; - } + // /* This may cause issues if cookies or javascript disabled + // if(!isset($_COOKIE['mail_name']) || trim($_COOKIE['mail_name'] == '')) { + // return false; + // } + // For checking session expire stuff if(!isset($_SESSION['start_stamp'])) { From 61c4b6346f180563cea6b4c6055f23ac539ac821 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Tue, 17 Sep 2024 06:07:26 -0700 Subject: [PATCH 3/8] Check multipart articles to try harder to find text/plain. --- Rocksolid_Light/rocksolid/lib/message.inc.php | 127 ++++++++++-------- 1 file changed, 68 insertions(+), 59 deletions(-) diff --git a/Rocksolid_Light/rocksolid/lib/message.inc.php b/Rocksolid_Light/rocksolid/lib/message.inc.php index 5388be0..8bb5cc1 100644 --- a/Rocksolid_Light/rocksolid/lib/message.inc.php +++ b/Rocksolid_Light/rocksolid/lib/message.inc.php @@ -38,7 +38,7 @@ function message_parse($rawmessage) $i = 0; while ($rawmessage[$i] != "") { $rawheader[] = $rawmessage[$i]; - $i ++; + $i++; } // Parse the Header: $message->header = parse_header($rawheader); @@ -50,19 +50,19 @@ function message_parse($rawmessage) $boundary = "--" . $message->header->content_type_boundary; // lets find the first part while ($rawmessage[$i] != $boundary) { - $i ++; + $i++; // Missing boundary line? - if(!$rawmessage[$i]) { + if (!$rawmessage[$i]) { break; } } - $i ++; + $i++; $part = array(); while ($i <= $count_rawmessage) { if (($rawmessage[$i] == $boundary) || ($i == $count_rawmessage - 1) || ($rawmessage[$i] == $boundary . '--')) { $partmessage = message_parse($part); // merge the content-types of the message with those of the part - for ($o = 0; $o < count($partmessage->header->content_type); $o ++) { + for ($o = 0; $o < count($partmessage->header->content_type); $o++) { $message->header->content_type[] = $partmessage->header->content_type[$o]; $message->header->content_type_charset[] = $partmessage->header->content_type_charset[$o]; $message->header->content_type_name[] = $partmessage->header->content_type_name[$o]; @@ -76,18 +76,18 @@ function message_parse($rawmessage) } if ($rawmessage[$i] == $boundary . '--') break; - $i ++; + $i++; } // Is this a multipart/alternative multipart-message? Do we have to // delete all non plain/text parts? if (($attachment_delete_alternative) && ($content_type[1] == "alternative")) { $plaintext = false; - for ($o = 0; $o < count($message->header->content_type); $o ++) { + for ($o = 0; $o < count($message->header->content_type); $o++) { if ($message->header->content_type[$o] == "text/plain") $plaintext = true; // we found at least one text/plain } if ($plaintext) { // now we can delete the other parts - for ($o = 0; $o < count($message->header->content_type); $o ++) { + for ($o = 0; $o < count($message->header->content_type); $o++) { if ($message->header->content_type[$o] != "text/plain") { unset($message->header->content_type[$o]); unset($message->header->content_type_name[$o]); @@ -102,8 +102,8 @@ function message_parse($rawmessage) // No mime-attachments in the message: $body = ""; $uueatt = 0; // as default we have no uuencoded attachments - // Handle inline attachments - for ($i ++; $i < $count_rawmessage; $i ++) { + // Handle inline attachments + for ($i++; $i < $count_rawmessage; $i++) { // do we have an inlay uuencoded file? if ((strtolower(substr($rawmessage[$i], 0, 10)) != "begin 644 ") || ($attachment_uudecode == false)) { $body .= $rawmessage[$i] . "\n"; @@ -115,12 +115,12 @@ function message_parse($rawmessage) $uue_infoline_raw = $rawmessage[$i]; $uue_infoline = explode(" ", $uue_infoline_raw); $uue_data = ""; - $i ++; + $i++; $no_end = 0; while ($rawmessage[$i] != "end") { if (strlen(trim($rawmessage[$i])) > 2) $uue_data .= $rawmessage[$i] . "\n"; - $i ++; + $i++; if ($i > $count_rawmessage) { $no_end = 1; break; @@ -128,10 +128,10 @@ function message_parse($rawmessage) } // now write the data in an attachment if ($no_end != 1) { - $uueatt ++; + $uueatt++; $message->body[$uueatt] = uudecode($uue_data); $message->header->content_type_name[$uueatt] = ""; - for ($o = 2; $o < count($uue_infoline); $o ++) + for ($o = 2; $o < count($uue_infoline); $o++) $message->header->content_type_name[$uueatt] .= $uue_infoline[$o]; $message->header->content_type[$uueatt] = get_mimetype_by_string($message->body[$uueatt]); } @@ -164,7 +164,7 @@ function message_parse($rawmessage) $message->header->content_type_format = array( "fixed" ); - for ($o = 0; $o < count($message->body); $o ++) { + for ($o = 0; $o < count($message->body); $o++) { if (! isset($message->header->content_type_charset[$o])) $message->header->content_type_charset[$o] = $www_charset; if (! isset($message->header->content_type_name[$o])) @@ -234,15 +234,15 @@ function message_read($id, $bodynum = 0, $group = "") unset($message->header); } // Is a non-existing attachment of an article requested? - if ((isset($message->header)) && ($bodynum != - 1) && (! isset($message->header->content_type[$bodynum]))) + if ((isset($message->header)) && ($bodynum != -1) && (! isset($message->header->content_type[$bodynum]))) return false; - if ((file_exists($cachefilename_body . $bodynum)) && ($bodynum != - 1)) { + if ((file_exists($cachefilename_body . $bodynum)) && ($bodynum != -1)) { $cachefile = fopen($cachefilename_body . $bodynum, "r"); $message->body[$bodynum] = fread($cachefile, filesize($cachefilename_body . $bodynum)); fclose($cachefile); } } - if ((! isset($message->header)) || ((! isset($message->body[$bodynum])) && ($bodynum != - 1))) { + if ((! isset($message->header)) || ((! isset($message->body[$bodynum])) && ($bodynum != -1))) { // Pull article from spool if exists, else from server if (trim($group) == '') { return false; @@ -301,7 +301,7 @@ function message_read($id, $bodynum = 0, $group = "") fputs($cachefile, serialize($message->header)); } fclose($cachefile); - for ($i = 0; $i < count($message->header->content_type); $i ++) { + for ($i = 0; $i < count($message->header->content_type); $i++) { if (isset($message->body[$i])) { $cachefile = fopen($cachefilename_body . $i, "w"); fwrite($cachefile, $message->body[$i]); @@ -328,10 +328,10 @@ function textwrap($text, $wrap = 80, $break = "\n", $maxlen = false) $lastWhite = 0; // position of last whitespace char $lastChar = 0; // position of last char $lastBreak = 0; // position of last break - // while there is text to process + // while there is text to process while ($lastChar < $len && (($maxlen == false) || (strlen($h) < $maxlen))) { $char = substr($text, $lastChar, 1); // get the next character - // if we are beyond the wrap boundry and there is a place to break + // if we are beyond the wrap boundry and there is a place to break if (($lastChar - $lastBreak > $wrap) && ($lastWhite > $lastBreak)) { $h .= substr($text, $lastBreak, ($lastWhite - $lastBreak)) . $break; $lastChar = $lastWhite + 1; @@ -425,9 +425,9 @@ function show_header($head, $group, $local_poster = false) if ($endname > 8) $endname = 8; if ($endname < 3) - $endname ++; + $endname++; if ($endname < 3) - $endname ++; + $endname++; } else { $endname = $namelen; } @@ -476,7 +476,7 @@ function show_header($head, $group, $local_poster = false) } if (($article_show["References"]) && (isset($head->references[0]))) { echo $text_header["references"]; - for ($i = 0; $i <= count($head->references) - 1; $i ++) { + for ($i = 0; $i <= count($head->references) - 1; $i++) { $ref = $head->references[$i]; echo ' ' . '' . ($i + 1) . ''; } @@ -491,7 +491,7 @@ function show_header($head, $group, $local_poster = false) } if ((isset($attachment_show)) && ($attachment_show == true) && (isset($head->content_type[1]))) { echo $text_header["attachments"]; - for ($i = 1; $i < count($head->content_type); $i ++) { + for ($i = 1; $i < count($head->content_type); $i++) { if (! strcmp($head->content_type[$i], "text/html")) { $contype = "HTML Version"; } else { @@ -559,22 +559,22 @@ function show_header_short($head, $group, $local_poster = false) echo 'window.getSelection().removeAllRanges();'; echo '}'; echo ' '; - ?> -

id); ?>

-  -copy - mid +?> +

id); ?>

+   + copy + mid -

number . '&group=' . urlencode($group) . '#' . $head->number; ?>

-  -copy - link +

number . '&group=' . urlencode($group) . '#' . $head->number; ?>

+   + copy + link newsgroups); @@ -607,7 +607,7 @@ function show_header_short($head, $group, $local_poster = false) if ((isset($attachment_show)) && ($attachment_show == true) && (isset($head->content_type[1]))) { echo '
'; echo $text_header["attachments"]; - for ($i = 1; $i < count($head->content_type); $i ++) { + for ($i = 1; $i < count($head->content_type); $i++) { if (! strcmp($head->content_type[$i], "text/html")) { $contype = "HTML Version"; } else { @@ -708,14 +708,14 @@ function decode_textbody($body, $format = "fixed") $depth = 0; $paragraph = ""; // empty paragraph $lastline = ""; - for ($i = 0; $i < count($body) + 1; $i ++) { + for ($i = 0; $i < count($body) + 1; $i++) { // calculate the quote depth of the actual line $ndepth = 0; $tdepth = 0; - for ($j = 0; $j <= strlen(@$body[$i]); $j ++) { + for ($j = 0; $j <= strlen(@$body[$i]); $j++) { $tdepth = $j; if (@$body[$i][$j] == '>') { - $ndepth ++; + $ndepth++; } else { if ((@$body[$i][$j] != ' ') || (@$body[$i][$j - 1] == ' ') || ($j == 0)) { break; @@ -839,16 +839,24 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl // Any header checks to display notice in article display $notice = display_header_notice($head); - - if(isset($head->content_type[0])) { - if(!strpos($head->content_type[0], "/")) { + if (isset($head->content_type[0])) { + if (!strpos($head->content_type[0], "/")) { echo '

(message #' . $head->number . ' not displayed - malformed header)


'; 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 (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]; + } + } + 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); @@ -901,13 +909,13 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl echo '
'; } $currentlen = 0; // needed if $maxlen is set - for ($i = 0; $i <= count($body) && (($currentlen < $maxlen) || ($maxlen == false)); $i ++) { + for ($i = 0; $i <= count($body) && (($currentlen < $maxlen) || ($maxlen == false)); $i++) { // HTMLized Quotings instead of boring > ? if ($article_graphicquotes) { // HTMLized Quotings - for ($j = $depth; $j < @$body[$i]->depth; $j ++) + for ($j = $depth; $j < @$body[$i]->depth; $j++) echo '
'; - for ($j = @$body[$i]->depth; $j < $depth; $j ++) + for ($j = @$body[$i]->depth; $j < $depth; $j++) echo '
'; $t = @$body[$i]->text; echo display_links_in_body($t); @@ -934,7 +942,7 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl // If attachment is image embed into article if ((isset($attachment_show)) && ($attachment_show == true) && (isset($head->content_type[1]))) { echo $text_header["attachments"]; - for ($i = 1; $i < count($head->content_type); $i ++) { + for ($i = 1; $i < count($head->content_type); $i++) { if (! strcmp($head->content_type[$i], "text/html")) { $contype = "HTML Version"; } else { @@ -981,13 +989,13 @@ function message_decrypt($key, $group, $id, $attachment = 0, $article_data = fal echo '
'; echo "(Copy text below to quote in reply)

"; $currentlen = 0; // needed if $maxlen is set - for ($i = 0; $i <= count($body) && (($currentlen < $maxlen) || ($maxlen == false)); $i ++) { + for ($i = 0; $i <= count($body) && (($currentlen < $maxlen) || ($maxlen == false)); $i++) { // HTMLized Quotings instead of boring > ? if ($article_graphicquotes) { // HTMLized Quotings - for ($j = $depth; $j < $body[$i]->depth; $j ++) + for ($j = $depth; $j < $body[$i]->depth; $j++) echo '
'; - for ($j = $body[$i]->depth; $j < $depth; $j ++) + for ($j = $body[$i]->depth; $j < $depth; $j++) echo '
'; $t = html_parse(text2html($body[$i]->text)) . '
'; echo $t; @@ -1030,7 +1038,7 @@ function articleflat_pageselect($group, $id, $article_count, $first) $return = ""; if ($article_count > $articleflat_articles_per_page) $return .= $text_thread["pages"]; - for ($i = 0; $i < $pages; $i ++) { + for ($i = 0; $i < $pages; $i++) { if ($first != $i * $articleflat_articles_per_page + 1) $return .= ''; else @@ -1047,12 +1055,13 @@ function articleflat_pageselect($group, $id, $article_count, $first) return $return; } -function display_header_notice($head) { +function display_header_notice($head) +{ $notice = false; - if(stripos($head->subject, "Re: ") === 0) { - if(!isset($head->references)) { + if (stripos($head->subject, "Re: ") === 0) { + if (!isset($head->references)) { $notice = '

(article missing references header)


'; } } return $notice; -} \ No newline at end of file +} From 54b27904b8c40ce3a6299e4462bdbaa58cff76cf Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Tue, 17 Sep 2024 06:45:52 -0700 Subject: [PATCH 4/8] Increment version to 0.9.153. --- Rocksolid_Light/common/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rocksolid_Light/common/version.txt b/Rocksolid_Light/common/version.txt index 3606c11..06b8730 100644 --- a/Rocksolid_Light/common/version.txt +++ b/Rocksolid_Light/common/version.txt @@ -1 +1 @@ -0.9.152 +0.9.153 From 43a61d7acd7ce4d80781e165bb27d931e6fce378 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Thu, 19 Sep 2024 03:35:43 -0700 Subject: [PATCH 5/8] More carefully check for end of message in spoolnews.php, avoiding lines that are not just a dot.lf --- Rocksolid_Light/rslight/scripts/spoolnews.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index 8ec0acc..ecf77a7 100644 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -252,7 +252,7 @@ function get_articles($ns, $group) file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Cannot get overview from " . $CONFIG['remote_server'] . " for " . $group . " (requested: xover " . $article . "-" . $getlast . " received " . $response . ")", FILE_APPEND); return false; } - while (trim($response = line_read($ns)) !== '.') { + while (rtrim($response = line_read($ns)) !== '.') { $ov = preg_split("/\t/", $response); $overview_msgid[$ov[0]] = $ov[4]; } From c2659424c8dc2825940c30fcd903683868e4e976 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Thu, 19 Sep 2024 05:19:26 -0700 Subject: [PATCH 6/8] Standardise line wrap width in config.inc.php, notify post of width. --- Rocksolid_Light/common/themes/style.css | 4 ++-- Rocksolid_Light/rocksolid/config.inc.php | 1 + Rocksolid_Light/rocksolid/newsportal.php | 10 +++++----- Rocksolid_Light/rocksolid/post.php | 6 ++++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Rocksolid_Light/common/themes/style.css b/Rocksolid_Light/common/themes/style.css index ee834f1..e8e2550 100644 --- a/Rocksolid_Light/common/themes/style.css +++ b/Rocksolid_Light/common/themes/style.css @@ -310,8 +310,8 @@ textarea.postbody { background-color: var(--color-medium); border: none; color: var(--color-text); - height: calc(1em * 1.5 * 20); - width: calc(1em * 1.5 * 40); + height: calc(1em * 40); + width: auto; } textarea.configuration { diff --git a/Rocksolid_Light/rocksolid/config.inc.php b/Rocksolid_Light/rocksolid/config.inc.php index 5ba3041..929f01f 100644 --- a/Rocksolid_Light/rocksolid/config.inc.php +++ b/Rocksolid_Light/rocksolid/config.inc.php @@ -216,6 +216,7 @@ if (isset($_SERVER["HTTP_HOST"])) { } $post_autoquote = false; $post_captcha = false; +$wrap_width = 72; /* * Attachments diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 46e2f1a..299fedd 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -3009,7 +3009,7 @@ function check_article_integrity($rawmessage) function wrap_post($body) { - $line_length = 72; + global $wrap_width; $lines = preg_split("/\n/", $body); $wrapped = ''; foreach ($lines as $line) { @@ -3026,11 +3026,11 @@ function wrap_post($body) break; } } - if (strlen($line) > $line_length) { + if (strlen($line) > $wrap_width) { // HERE is where we wrap quoted lines (not so easy) $start = substr($line, 0, $depth + 1); $end = substr($line, $depth + 1); - $line_wrapped = $start . mb_wordwrap($end, $line_length); + $line_wrapped = $start . mb_wordwrap($end, $wrap_width); $line_wrapped = preg_split("/\n/", $line_wrapped); foreach ($line_wrapped as $lw) { if ($lw[0] != '>') { @@ -3047,9 +3047,9 @@ function wrap_post($body) $wrapped .= $line . "\n"; } } else { - if (strlen($line) > $line_length) { + if (strlen($line) > $wrap_width) { // HERE is where we wrap NON quoted lines (easy) - $wrapped .= mb_wordwrap($line, $line_length) . "\n"; + $wrapped .= mb_wordwrap($line, $wrap_width) . "\n"; } else { $wrapped .= $line . "\n"; } diff --git a/Rocksolid_Light/rocksolid/post.php b/Rocksolid_Light/rocksolid/post.php index ca35f07..0e3495a 100644 --- a/Rocksolid_Light/rocksolid/post.php +++ b/Rocksolid_Light/rocksolid/post.php @@ -590,8 +590,10 @@ if ($show == 1) { echo '
'; echo ''; - echo '
' . $text_post["message"] . '