diff --git a/.env.example b/.env.example index cacb795..ee9b45c 100644 --- a/.env.example +++ b/.env.example @@ -29,7 +29,7 @@ REDIS_PASSWORD= REDIS_PORT=6379 MAIL_DRIVER=smtp -MAIL_HOST=mail.leenooks.lan +MAIL_HOST=mail.dege.lan MAIL_PORT=25 MAIL_USERNAME= MAIL_PASSWORD= diff --git a/.env.testing b/.env.testing index 6d825f8..bca7f1d 100644 --- a/.env.testing +++ b/.env.testing @@ -2,7 +2,8 @@ APP_NAME="Clearing Houz Testing" APP_ENV=testing APP_KEY=base64:FiMSvv4J7jDfy6W/sHrQ9YImuUYaxynYCcXQJwp/6Tc= APP_DEBUG=true -#APP_URL=http://localhost +APP_URL=http://localhost +APP_TIMEZONE=Australia/Melbourne LOG_CHANNEL=stderr LOG_LEVEL=debug @@ -14,10 +15,6 @@ DB_DATABASE=test DB_USERNAME=test DB_PASSWORD=test -DB_MONGO_HOST=mongo -DB_MONGO_USERNAME=mongo -DB_MONGO_PASSWORD=password - BROADCAST_DRIVER=log CACHE_DRIVER=file QUEUE_CONNECTION=sync @@ -43,3 +40,14 @@ PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +FIDO_DIR=fido +FIDO_PACKET_KEEP=true + +FILESYSTEM_DISK=s3 +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_BUCKET= +AWS_ENDPOINT= +AWS_DEFAULT_REGION= +AWS_USE_PATH_STYLE_ENDPOINT= diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index a34cc61..6ecdee0 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -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); } diff --git a/phpunit.xml b/phpunit.xml index c273583..f112c0c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,28 +1,31 @@ - - - - ./tests/Unit - - - ./tests/Feature - - - - - - - - - - - - - - - - - ./app - - + + + + tests/Unit + + + tests/Feature + + + + + app + + + + + + + + + + + + + diff --git a/resources/views/pkt.blade.php b/resources/views/pkt.blade.php index 726e900..2719533 100644 --- a/resources/views/pkt.blade.php +++ b/resources/views/pkt.blade.php @@ -119,6 +119,14 @@ + @if($msg->tagline) +
+
+ TAGLINE:
{{ $msg->tagline }} +
+
+ @endif + @if($msg->isNetmail())
diff --git a/tests/Feature/PacketTest.php b/tests/Feature/PacketTest.php index b0ba45a..dc5b836 100644 --- a/tests/Feature/PacketTest.php +++ b/tests/Feature/PacketTest.php @@ -201,4 +201,55 @@ class PacketTest extends TestCase $this->assertTrue($messages); } } + + public function test_soh_in_origin() + { + // This packet has a SOHSOH sequence + $f = new File(__DIR__.'/data/test_msg_with_soh_in_origin.pkt'); + + foreach ($f as $packet) { + $pkt = Packet::process($packet,$f->itemName(),$f->itemSize(),NULL,FALSE); + + $this->assertEquals(9,$pkt->count()); + + $messages = FALSE; + $c = 0; + foreach ($pkt as $msg) { + $c++; + $messages = TRUE; + + $this->assertNotTrue($msg->isNetmail()); + + switch ($c) { + case 1: + $this->assertSame('3:712/886 220da89f',$msg->msgid); + $this->assertSame('9f5544bea46ef57a45f561b9e07dd71e',md5($msg->message)); + $this->assertSame('9bf4b8c348ac235cc218577abf7140af',md5($msg->message_src)); + $this->assertCount(3,$msg->rogue_path); + $this->assertCount(16,$msg->rogue_seenby); + $this->assertContains('633/0 267 280 281 408 410 412 509 509 640/1384 712/114 550 620 848',$msg->seenby); + $this->assertContains('712/886 848 633/280',$msg->path); + $this->assertCount(2,$msg->seenby); + $this->assertCount(0,$msg->unknown); + break; + + case 4: + $this->assertSame('',$msg->msgid); + $this->assertSame('b975057002def556c5a9497aacd000fb',md5($msg->message)); + $this->assertSame('c90dd234d2aa029af22c453a25b79a4e',md5($msg->message_src)); + $this->assertCount(3,$msg->rogue_path); + $this->assertCount(19,$msg->rogue_seenby); + $this->assertContains('633/267 280 281 384 408 410 412 418 420 509 509 712/848 770/1 100 330',$msg->seenby); + $this->assertContains('772/210 770/1 633/280',$msg->path); + $this->assertCount(2,$msg->seenby); + $this->assertCount(0,$msg->unknown); + + default: + continue 2; + } + } + + $this->assertTrue($messages); + } + } } diff --git a/tests/Feature/data/test_msg_with_soh_in_origin.pkt b/tests/Feature/data/test_msg_with_soh_in_origin.pkt new file mode 100644 index 0000000..d1bbe8f Binary files /dev/null and b/tests/Feature/data/test_msg_with_soh_in_origin.pkt differ