Finish improving multiline header handling.
This commit is contained in:
parent
2bbc019daf
commit
98cacd2682
|
@ -337,6 +337,7 @@ function process_post($message, $group)
|
||||||
$is_header = 1;
|
$is_header = 1;
|
||||||
$body = "";
|
$body = "";
|
||||||
$ref = 0;
|
$ref = 0;
|
||||||
|
$sub = 0;
|
||||||
$response = "";
|
$response = "";
|
||||||
$bytes = 0;
|
$bytes = 0;
|
||||||
$lines = 0;
|
$lines = 0;
|
||||||
|
@ -350,6 +351,10 @@ function process_post($message, $group)
|
||||||
if ($is_header == 0) {
|
if ($is_header == 0) {
|
||||||
$body .= $line . "\n";
|
$body .= $line . "\n";
|
||||||
} else {
|
} else {
|
||||||
|
if (strpos($line, ': ') !== false) {
|
||||||
|
$ref = 0;
|
||||||
|
$sub = 0;
|
||||||
|
}
|
||||||
if (stripos($line, "Date: ") === 0) {
|
if (stripos($line, "Date: ") === 0) {
|
||||||
$finddate = explode(': ', $line);
|
$finddate = explode(': ', $line);
|
||||||
$article_date = strtotime($finddate[1]);
|
$article_date = strtotime($finddate[1]);
|
||||||
|
@ -359,31 +364,30 @@ function process_post($message, $group)
|
||||||
$no_org = 0;
|
$no_org = 0;
|
||||||
}
|
}
|
||||||
if (stripos($line, "Subject: ") !== false) {
|
if (stripos($line, "Subject: ") !== false) {
|
||||||
$subject = explode('Subject: ', $line, 2);
|
$this_subject = explode('Subject: ', $line, 2);
|
||||||
$ref = 0;
|
$subject = $this_subject[1];
|
||||||
|
$sub = 1;
|
||||||
}
|
}
|
||||||
if (stripos($line, "From: ") === 0) {
|
if (stripos($line, "From: ") === 0) {
|
||||||
$from = explode(': ', $line);
|
$from = explode(': ', $line);
|
||||||
$ref = 0;
|
|
||||||
}
|
}
|
||||||
if (stripos($line, "Xref: ") === 0) {
|
if (stripos($line, "Xref: ") === 0) {
|
||||||
$xref = $line;
|
$xref = $line;
|
||||||
$ref = 0;
|
|
||||||
}
|
}
|
||||||
if (stripos($line, "Newsgroups: ") === 0) {
|
if (stripos($line, "Newsgroups: ") === 0) {
|
||||||
$ngroups = explode(': ', $line);
|
$ngroups = explode(': ', $line);
|
||||||
$newsgroups = $ngroups[1];
|
$newsgroups = $ngroups[1];
|
||||||
$ref = 0;
|
|
||||||
}
|
}
|
||||||
if (stripos($line, "References: ") === 0) {
|
if (stripos($line, "References: ") === 0) {
|
||||||
$references_line = explode(': ', $line);
|
$references_line = explode(': ', $line);
|
||||||
$references = $references_line[1];
|
$references = $references_line[1];
|
||||||
$ref = 1;
|
$ref = 1;
|
||||||
}
|
}
|
||||||
if ((stripos($line, ':') === false) && (strpos($line, '>'))) {
|
if (preg_match('/^\s/', $line) && $ref == 1) {
|
||||||
if ($ref == 1) {
|
$references = $references . $line;
|
||||||
$references = $references . " " . trim($line);
|
|
||||||
}
|
}
|
||||||
|
if (preg_match('/^\s/', $line) && $sub == 1) {
|
||||||
|
$subject = $subject . $line;
|
||||||
}
|
}
|
||||||
if (stripos($line, "Message-ID: ") !== false) {
|
if (stripos($line, "Message-ID: ") !== false) {
|
||||||
$mid = explode(': ', $line);
|
$mid = explode(': ', $line);
|
||||||
|
@ -395,7 +399,7 @@ function process_post($message, $group)
|
||||||
* SPAM CHECK
|
* SPAM CHECK
|
||||||
*/
|
*/
|
||||||
if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true)) {
|
if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true)) {
|
||||||
$spam_result_array = check_spam($subject[1], $from[1], $newsgroups, $references, $body, $msgid, true);
|
$spam_result_array = check_spam($subject, $from[1], $newsgroups, $references, $body, $msgid, true);
|
||||||
$res = $spam_result_array['res'];
|
$res = $spam_result_array['res'];
|
||||||
$spamresult = $spam_result_array['spamresult'];
|
$spamresult = $spam_result_array['spamresult'];
|
||||||
$spamcheckerversion = $spam_result_array['spamcheckerversion'];
|
$spamcheckerversion = $spam_result_array['spamcheckerversion'];
|
||||||
|
@ -422,7 +426,7 @@ function process_post($message, $group)
|
||||||
$date_rep = $finddate[1];
|
$date_rep = $finddate[1];
|
||||||
}
|
}
|
||||||
if ($no_mid == 1) {
|
if ($no_mid == 1) {
|
||||||
$identity = $subject[1] . "," . $from[1] . "," . $ngroups[1] . "," . $references . "," . $body;
|
$identity = $subject . "," . $from[1] . "," . $ngroups[1] . "," . $references . "," . $body;
|
||||||
$msgid = '<' . md5($identity) . '$1@' . trim($CONFIG['email_tail'], '@') . '>';
|
$msgid = '<' . md5($identity) . '$1@' . trim($CONFIG['email_tail'], '@') . '>';
|
||||||
fputs($postfilehandle, "Message-ID: " . $msgid . "\r\n");
|
fputs($postfilehandle, "Message-ID: " . $msgid . "\r\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -455,7 +459,7 @@ function process_post($message, $group)
|
||||||
if ($section == "") {
|
if ($section == "") {
|
||||||
$response = "441 Posting failed (section not found)\r\n";
|
$response = "441 Posting failed (section not found)\r\n";
|
||||||
} else {
|
} else {
|
||||||
$response = insert_article($section, $group, $postfilename, $subject[1], $from[1], $article_date, $date_rep, $msgid, $references, $bytes, $lines, $xref, $body);
|
$response = insert_article($section, $group, $postfilename, $subject, $from[1], $article_date, $date_rep, $msgid, $references, $bytes, $lines, $xref, $body);
|
||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,6 +261,7 @@ function get_articles($ns, $group)
|
||||||
$lines = 0;
|
$lines = 0;
|
||||||
$bytes = 0;
|
$bytes = 0;
|
||||||
$ref = 0;
|
$ref = 0;
|
||||||
|
$sub = 0;
|
||||||
$banned = false;
|
$banned = false;
|
||||||
$is_header = 1;
|
$is_header = 1;
|
||||||
$body = "";
|
$body = "";
|
||||||
|
@ -277,6 +278,7 @@ function get_articles($ns, $group)
|
||||||
$response = str_replace("\t", " ", $response);
|
$response = str_replace("\t", " ", $response);
|
||||||
if (strpos($response, ': ') !== false) {
|
if (strpos($response, ': ') !== false) {
|
||||||
$ref = 0;
|
$ref = 0;
|
||||||
|
$sub = 0;
|
||||||
}
|
}
|
||||||
// Find article date
|
// Find article date
|
||||||
if (stripos($response, "Date: ") === 0) {
|
if (stripos($response, "Date: ") === 0) {
|
||||||
|
@ -303,8 +305,10 @@ function get_articles($ns, $group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stripos($response, "Subject: ") === 0) {
|
if (stripos($response, "Subject: ") === 0) {
|
||||||
$subject = explode('Subject: ', $response, 2);
|
$this_subject = explode('Subject: ', $response, 2);
|
||||||
if (preg_match($subject_filter, $subject[1])) {
|
$subject = $this_subject[1];
|
||||||
|
$sub = 1;
|
||||||
|
if (preg_match($subject_filter, $subject)) {
|
||||||
$banned = "subject_filter";
|
$banned = "subject_filter";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,6 +352,9 @@ function get_articles($ns, $group)
|
||||||
if (preg_match('/^\s/', $response) && $ref == 1) {
|
if (preg_match('/^\s/', $response) && $ref == 1) {
|
||||||
$references = $references . $response;
|
$references = $references . $response;
|
||||||
}
|
}
|
||||||
|
if (preg_match('/^\s/', $response) && $sub == 1) {
|
||||||
|
$subject = $subject . $response;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$body .= $response . "\n";
|
$body .= $response . "\n";
|
||||||
}
|
}
|
||||||
|
@ -375,7 +382,7 @@ function get_articles($ns, $group)
|
||||||
$article ++;
|
$article ++;
|
||||||
} else {
|
} else {
|
||||||
if ((strpos($CONFIG['nocem_groups'], $group) !== false) && ($CONFIG['enable_nocem'] == true)) {
|
if ((strpos($CONFIG['nocem_groups'], $group) !== false) && ($CONFIG['enable_nocem'] == true)) {
|
||||||
if (strpos($subject[1], $nocem_check) !== false) {
|
if (strpos($subject, $nocem_check) !== false) {
|
||||||
$is_from = address_decode($from[1], 'nowhere');
|
$is_from = address_decode($from[1], 'nowhere');
|
||||||
$nocem_file = tempnam($spooldir . "/nocem", $is_from[0]['mailbox'] . "@" . $is_from[0]['host'] . "[" . date("Y.m.d.H.i.s") . "]");
|
$nocem_file = tempnam($spooldir . "/nocem", $is_from[0]['mailbox'] . "@" . $is_from[0]['host'] . "[" . date("Y.m.d.H.i.s") . "]");
|
||||||
copy($articleHandle, $nocem_file);
|
copy($articleHandle, $nocem_file);
|
||||||
|
@ -387,8 +394,8 @@ function get_articles($ns, $group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((strpos($rslight_gpg['nntp_group'], $group) !== false) && ($rslight_gpg['enable'] == '1')) {
|
if ((strpos($rslight_gpg['nntp_group'], $group) !== false) && ($rslight_gpg['enable'] == '1')) {
|
||||||
if (strpos($subject[1], $bbsmail_check) !== false) {
|
if (strpos($subject, $bbsmail_check) !== false) {
|
||||||
$bbsmail_file = preg_replace('/@@RSL /', '', $subject[1]);
|
$bbsmail_file = preg_replace('/@@RSL /', '', $subject);
|
||||||
$bbsmail_filename = $spooldir . "/bbsmail/in/bbsmail-" . $bbsmail_file;
|
$bbsmail_filename = $spooldir . "/bbsmail/in/bbsmail-" . $bbsmail_file;
|
||||||
copy($articleHandle, $bbsmail_filename);
|
copy($articleHandle, $bbsmail_filename);
|
||||||
}
|
}
|
||||||
|
@ -408,7 +415,7 @@ function get_articles($ns, $group)
|
||||||
$current_article['epochdate'] = $article_date;
|
$current_article['epochdate'] = $article_date;
|
||||||
$current_article['stringdate'] = $finddate[1];
|
$current_article['stringdate'] = $finddate[1];
|
||||||
$current_article['from'] = $from[1];
|
$current_article['from'] = $from[1];
|
||||||
$current_article['subject'] = $subject[1];
|
$current_article['subject'] = $subject;
|
||||||
$current_article['references'] = $references;
|
$current_article['references'] = $references;
|
||||||
$current_article['bytes'] = $bytes;
|
$current_article['bytes'] = $bytes;
|
||||||
$current_article['lines'] = $lines;
|
$current_article['lines'] = $lines;
|
||||||
|
@ -418,7 +425,7 @@ function get_articles($ns, $group)
|
||||||
// Check Spam
|
// Check Spam
|
||||||
$res = 0;
|
$res = 0;
|
||||||
if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true) && ($OVERRIDES['disable_spamassassin_spooling'] !== true)) {
|
if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true) && ($OVERRIDES['disable_spamassassin_spooling'] !== true)) {
|
||||||
$spam_result_array = check_spam($subject[1], $from[1], $groupnames[1], $references, $this_article, $mid[1]);
|
$spam_result_array = check_spam($subject, $from[1], $groupnames[1], $references, $this_article, $mid[1]);
|
||||||
$res = $spam_result_array['res'];
|
$res = $spam_result_array['res'];
|
||||||
$spamresult = $spam_result_array['spamresult'];
|
$spamresult = $spam_result_array['spamresult'];
|
||||||
$spamcheckerversion = $spam_result_array['spamcheckerversion'];
|
$spamcheckerversion = $spam_result_array['spamcheckerversion'];
|
||||||
|
|
Loading…
Reference in New Issue