Another fix for when packets contain binary messages with SOH chars.

This commit is contained in:
Deon George 2021-11-29 00:12:37 +11:00
parent 880ff81eff
commit a00534794e
3 changed files with 34 additions and 3 deletions

View File

@ -692,9 +692,16 @@ class Message extends FTNBase
// 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 (strlen($this->message) || ($retpos !== strlen($kl)-1)) {
// If there was no return, its part of the message.
if ($retpos === FALSE) {
$this->message .= "\x01".$kl;
continue;
}
// Anything after the origin line is also kludge data.
if (($originpos = strpos($kl,"\r * Origin: "))) {
if ($originpos = strpos($kl,"\r * Origin: ")) {
if (! $this->message) {
$this->message .= substr($kl,$retpos+1,$originpos-$retpos-1);
$this->parseOrigin(substr($kl,$originpos+1));

View File

@ -118,7 +118,31 @@ class PacketTest extends TestCase
public function test_packet_parse()
{
// This packet has an incorrect zone in the Origin
// This packet has a SOH<char>SOH sequence
$f = new File(__DIR__.'/data/test_binary_content-2.pkt');
$pkt = Packet::open($f,NULL,FALSE);
$this->assertEquals(1,$pkt->count());
$messages = FALSE;
foreach ($pkt as $msg) {
$messages = TRUE;
$this->assertNotTrue($msg->isNetmail());
$this->assertSame('21:1/151 6189F64C',$msg->msgid);
$this->assertSame('db727bd3778ddd457784ada4bf016010',md5($msg->message));
$this->assertSame('5b627ab5936b0550a97b738f4deff419',md5($msg->message_src));
$this->assertCount(3,$msg->rogue_path);
$this->assertCount(170,$msg->rogue_seen);
$this->assertContains('3/2744 4/100 106 5/100',$msg->seenby);
$this->assertContains('1/151 100 3/100',$msg->path);
$this->assertCount(11,$msg->seenby);
$this->assertCount(0,$msg->unknown);
}
$this->assertTrue($messages);
// This packet has SOH in the message content
$f = new File(__DIR__.'/data/test_binary_content.pkt');
$pkt = Packet::open($f,NULL,FALSE);

Binary file not shown.