diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index bcdae37..f6f1f66 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -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)); diff --git a/tests/Feature/PacketTest.php b/tests/Feature/PacketTest.php index 632a60d..61f71a3 100644 --- a/tests/Feature/PacketTest.php +++ b/tests/Feature/PacketTest.php @@ -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 SOHSOH 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); diff --git a/tests/Feature/data/test_binary_content-2.pkt b/tests/Feature/data/test_binary_content-2.pkt new file mode 100644 index 0000000..445efbb Binary files /dev/null and b/tests/Feature/data/test_binary_content-2.pkt differ