Handle multiline Newsgroups header when posted directly to rslight nntp server.

This commit is contained in:
Retro_Guy 2024-05-28 04:33:26 -07:00
parent e6627d448b
commit 3dd359f89f
1 changed files with 29 additions and 10 deletions

View File

@ -374,6 +374,22 @@ function process_post($message, $group)
$ref = 0;
$sub = 0;
$ng = 0;
} else {
if (preg_match('/^\s/', $line)) {
if ($ng == 1) {
$newsgroups = $newsgroups . ',' . trim($line);
$newsgroups = preg_replace('/\,\,/', ',', $newsgroups);
continue;
}
if ($ref == 1) {
$references = $references . $line;
continue;
}
if ($sub == 1) {
$subject = $subject . $line;
continue;
}
}
}
if (stripos($line, "Path: ") === 0) {
$response = "441 Posting failed (Header preloading denied)\r\n";
@ -412,15 +428,7 @@ function process_post($message, $group)
$references = $references_line[1];
$ref = 1;
}
if (preg_match('/^\s/', $line) && $ng == 1) {
$newsgroups .= $newsgroups;
}
if (preg_match('/^\s/', $line) && $ref == 1) {
$references = $references . $line;
}
if (preg_match('/^\s/', $line) && $sub == 1) {
$subject = $subject . $line;
}
if (stripos($line, "Message-ID: ") !== false) {
$mid = explode(': ', $line);
$no_mid = 0;
@ -476,6 +484,7 @@ function process_post($message, $group)
}
$is_header = 1;
$lines = 0;
$ng = 0;
foreach ($message as $line) {
if (trim($line) == "" || $lines > 0) {
$is_header = 0;
@ -483,7 +492,17 @@ function process_post($message, $group)
}
if (stripos($line, "Newsgroups: ") === 0 && $is_header == 1) {
fputs($postfilehandle, "Newsgroups: " . $newsgroups . "\r\n");
$ng = 1;
} else {
if (strpos($line, ': ') !== false) {
$ng = 0;
} else {
if (preg_match('/^\s/', $line)) {
if ($ng == 1) {
continue;
}
}
}
fputs($postfilehandle, $line . "\r\n");
}
}
@ -1131,7 +1150,7 @@ function insert_article($section, $nntp_group, $filename, $subject_i, $from_i, $
{
global $enable_rslight, $spooldir, $CONFIG, $OVERRIDES, $logdir, $lockdir, $logfile;
if(is_moderated($nntp_group)) {
if (is_moderated($nntp_group)) {
file_put_contents($logfile, "\n" . format_log_date() . " " . $section . " Moderated group... Queuing local post: " . $nntp_group, FILE_APPEND);
$return_val = "240 Article received OK (queued for moderation)\r\n";
return ($return_val);