Fix for when packets have a kludge after the origin line, and now capturing taglines. Updated testing configuration

This commit is contained in:
2023-08-04 22:06:29 +10:00
parent fb65c645cb
commit c8a2affbfa
7 changed files with 152 additions and 47 deletions

View File

@@ -212,8 +212,8 @@ class Message extends FTNBase
$this->echoarea = '';
$this->intl = '';
$this->tearline = '';
$this->tagline = '';
$this->tearline = NULL;
$this->tagline = NULL;
$this->origin = '';
$this->tzutc = 0;
@@ -733,7 +733,9 @@ class Message extends FTNBase
// Split out each line
$result = collect(explode("\r",$message))->filter();
foreach ($result as $v) {
while ($result->count()) {
$v = $result->shift();
foreach ($this->_kludge as $a => $b) {
if ($t = $this->kludge($b,$v)) {
$this->kludge->put($a,$t);
@@ -747,8 +749,16 @@ class Message extends FTNBase
elseif ($t = $this->kludge('PATH: ', $v))
$this->path->push($t);
elseif ($t = $this->kludge(' \* Origin: ',$v))
$this->origin = $t;
elseif ($t = $this->kludge(' \* Origin: ',$v)) {
// Check in case there is a kludge that starts with SOH
if ($soh=strpos($t,"\x01")) {
$this->origin = substr($t,0,$soh);
$result->push(substr($t,$soh+1));
} else {
$this->origin = $t;
}
}
// We got unknown Kludge lines in the origin
else
@@ -816,38 +826,56 @@ class Message extends FTNBase
$this->message = '';
$this->message_src = '';
$msgpos = 0;
$haveOrigin = FALSE;
foreach ($result as $kl) {
while ($result->count()) {
// $kl is our line starting with a \x01 kludge delimiter
$kl = $result->shift();
// Search for \r - if that is the end of the line, then its a kludge
$retpos = strpos($kl,"\r");
$msgpos += 1+strlen($kl); // SOH+text
$t = '';
// If there are is a return in this middle of this line, that means the text message starts after the return
// If our message has started, then we'll assume the binary is part of the message.
if (strlen($this->message) || ($retpos !== strlen($kl)-1)) {
// If there is a return in this middle of this line, that means the text message starts after the return,
// ie: SOH+text\rmessage
// If there was no return, its part of the message.
// Just in case we already parsed this as part of our message, we'll continue, since its probably a
// binary message with a SOH inside it.
if (strlen($this->message) || ($retpos !== strlen($kl)-1)) {
// If there was no return, its part of the message, so we need to add back the SOH.
if ($retpos === FALSE) {
$this->message .= "\x01".$kl;
continue;
}
// Anything after the origin line is also kludge data.
if ($originpos = strrpos($kl,"\r * Origin: ")) {
// Check if this has the origin line. Anything before is the message, anything after the origin
// line is also kludge data.
if ($originpos=strrpos($kl,"\r * Origin: ")) {
// Anything after the return (from the kludge) is a message.
if (! $this->message) {
$this->message .= substr($kl,$retpos+1,$originpos-$retpos-1);
// But if we are already sourcing a message, then its part of it message.
} else {
$this->message .= "\x01".substr($kl,0,$originpos);
$retpos = 0;
}
// See if we have a tagline
if ($tl=strrpos($kl,"\r... ")) {
$tlr = strpos(substr($kl,$tl+6),"\r");
$this->tagline = substr($kl,$tl+5,$tlr);
}
// Message is finished, now we are parsing origin data (and more kludges)
$this->parseOrigin(substr($kl,$originpos+1));
$haveOrigin = TRUE;
// Our message source (for resending, is everything up to the end of the origin line.
$this->message_src = substr($message, 0, $msgpos - (1+strlen($kl)) + $originpos + 12 + strlen($this->origin) + 1);
$kl = substr($kl,0,$retpos);
@@ -876,11 +904,18 @@ class Message extends FTNBase
}
// The message is the rest?
// Netmails dont generally have an origin line
} elseif (strlen($kl) > $retpos+1) {
// Since netmail doesnt have an origin - our source:
$this->message .= substr($kl,$retpos+1);
$this->message_src = substr($message, 0, $msgpos);
// We still have some text to process, add it to the list
if ($haveOrigin && ($retpos+1 < strlen($kl))) {
$result->push(substr($kl,$retpos+1));
// If this was the overflow from echomail, then our message_src would be defined, and thus its not part of the message
} else {
$this->message .= substr($kl,$retpos+1);
$this->message_src = substr($message, 0, $msgpos);
}
$kl = substr($kl,0,$retpos);
}