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

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

View File

@ -29,7 +29,7 @@ REDIS_PASSWORD=
REDIS_PORT=6379 REDIS_PORT=6379
MAIL_DRIVER=smtp MAIL_DRIVER=smtp
MAIL_HOST=mail.leenooks.lan MAIL_HOST=mail.dege.lan
MAIL_PORT=25 MAIL_PORT=25
MAIL_USERNAME= MAIL_USERNAME=
MAIL_PASSWORD= MAIL_PASSWORD=

View File

@ -2,7 +2,8 @@ APP_NAME="Clearing Houz Testing"
APP_ENV=testing APP_ENV=testing
APP_KEY=base64:FiMSvv4J7jDfy6W/sHrQ9YImuUYaxynYCcXQJwp/6Tc= APP_KEY=base64:FiMSvv4J7jDfy6W/sHrQ9YImuUYaxynYCcXQJwp/6Tc=
APP_DEBUG=true APP_DEBUG=true
#APP_URL=http://localhost APP_URL=http://localhost
APP_TIMEZONE=Australia/Melbourne
LOG_CHANNEL=stderr LOG_CHANNEL=stderr
LOG_LEVEL=debug LOG_LEVEL=debug
@ -14,10 +15,6 @@ DB_DATABASE=test
DB_USERNAME=test DB_USERNAME=test
DB_PASSWORD=test DB_PASSWORD=test
DB_MONGO_HOST=mongo
DB_MONGO_USERNAME=mongo
DB_MONGO_PASSWORD=password
BROADCAST_DRIVER=log BROADCAST_DRIVER=log
CACHE_DRIVER=file CACHE_DRIVER=file
QUEUE_CONNECTION=sync QUEUE_CONNECTION=sync
@ -43,3 +40,14 @@ PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 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=

View File

@ -212,8 +212,8 @@ class Message extends FTNBase
$this->echoarea = ''; $this->echoarea = '';
$this->intl = ''; $this->intl = '';
$this->tearline = ''; $this->tearline = NULL;
$this->tagline = ''; $this->tagline = NULL;
$this->origin = ''; $this->origin = '';
$this->tzutc = 0; $this->tzutc = 0;
@ -733,7 +733,9 @@ class Message extends FTNBase
// Split out each line // Split out each line
$result = collect(explode("\r",$message))->filter(); $result = collect(explode("\r",$message))->filter();
foreach ($result as $v) { while ($result->count()) {
$v = $result->shift();
foreach ($this->_kludge as $a => $b) { foreach ($this->_kludge as $a => $b) {
if ($t = $this->kludge($b,$v)) { if ($t = $this->kludge($b,$v)) {
$this->kludge->put($a,$t); $this->kludge->put($a,$t);
@ -747,8 +749,16 @@ class Message extends FTNBase
elseif ($t = $this->kludge('PATH: ', $v)) elseif ($t = $this->kludge('PATH: ', $v))
$this->path->push($t); $this->path->push($t);
elseif ($t = $this->kludge(' \* Origin: ',$v)) elseif ($t = $this->kludge(' \* Origin: ',$v)) {
$this->origin = $t; // 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 // We got unknown Kludge lines in the origin
else else
@ -816,38 +826,56 @@ class Message extends FTNBase
$this->message = ''; $this->message = '';
$this->message_src = ''; $this->message_src = '';
$msgpos = 0; $msgpos = 0;
$haveOrigin = FALSE;
foreach ($result as $kl) { while ($result->count()) {
// $kl is our line starting with a \x01 kludge delimiter // $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 // Search for \r - if that is the end of the line, then its a kludge
$retpos = strpos($kl,"\r"); $retpos = strpos($kl,"\r");
$msgpos += 1+strlen($kl); // SOH+text $msgpos += 1+strlen($kl); // SOH+text
$t = ''; $t = '';
// If there are is a return in this middle of this line, that means the text message starts after the return // If there 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. // ie: SOH+text\rmessage
if (strlen($this->message) || ($retpos !== strlen($kl)-1)) {
// 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) { if ($retpos === FALSE) {
$this->message .= "\x01".$kl; $this->message .= "\x01".$kl;
continue; continue;
} }
// Anything after the origin line is also kludge data. // Check if this has the origin line. Anything before is the message, anything after the origin
if ($originpos = strrpos($kl,"\r * 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) { if (! $this->message) {
$this->message .= substr($kl,$retpos+1,$originpos-$retpos-1); $this->message .= substr($kl,$retpos+1,$originpos-$retpos-1);
// But if we are already sourcing a message, then its part of it message.
} else { } else {
$this->message .= "\x01".substr($kl,0,$originpos); $this->message .= "\x01".substr($kl,0,$originpos);
$retpos = 0; $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)); $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); $this->message_src = substr($message, 0, $msgpos - (1+strlen($kl)) + $originpos + 12 + strlen($this->origin) + 1);
$kl = substr($kl,0,$retpos); $kl = substr($kl,0,$retpos);
@ -876,11 +904,18 @@ class Message extends FTNBase
} }
// The message is the rest? // The message is the rest?
// Netmails dont generally have an origin line
} elseif (strlen($kl) > $retpos+1) { } 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); $kl = substr($kl,0,$retpos);
} }

View File

@ -1,28 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true"> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<testsuites> xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
<testsuite name="Unit"> bootstrap="vendor/autoload.php"
<directory suffix="Test.php">./tests/Unit</directory> colors="true"
</testsuite> >
<testsuite name="Feature"> <testsuites>
<directory suffix="Test.php">./tests/Feature</directory> <testsuite name="Unit">
</testsuite> <directory>tests/Unit</directory>
</testsuites> </testsuite>
<coverage/> <testsuite name="Feature">
<php> <directory>tests/Feature</directory>
<env name="APP_ENV" value="testing"/> </testsuite>
<env name="BCRYPT_ROUNDS" value="4"/> </testsuites>
<env name="CACHE_DRIVER" value="array"/> <source>
<!-- <env name="DB_CONNECTION" value="sqlite"/> --> <include>
<!-- <env name="DB_DATABASE" value=":memory:"/> --> <directory>app</directory>
<env name="MAIL_MAILER" value="array"/> </include>
<env name="QUEUE_CONNECTION" value="sync"/> </source>
<env name="SESSION_DRIVER" value="array"/> <php>
<env name="TELESCOPE_ENABLED" value="false"/> <env name="APP_ENV" value="testing"/>
</php> <env name="BCRYPT_ROUNDS" value="4"/>
<source> <env name="CACHE_DRIVER" value="array"/>
<include> <!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<directory suffix=".php">./app</directory> <!-- <env name="DB_DATABASE" value=":memory:"/> -->
</include> <env name="MAIL_MAILER" value="array"/>
</source> <env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/>
</php>
</phpunit> </phpunit>

View File

@ -119,6 +119,14 @@
</div> </div>
</div> </div>
@if($msg->tagline)
<div class="row pb-2">
<div class="col-8">
TAGLINE: <br><strong class="highlight">{{ $msg->tagline }}</strong>
</div>
</div>
@endif
@if($msg->isNetmail()) @if($msg->isNetmail())
<div class="row pb-2"> <div class="row pb-2">
<div class="col-8"> <div class="col-8">

View File

@ -201,4 +201,55 @@ class PacketTest extends TestCase
$this->assertTrue($messages); $this->assertTrue($messages);
} }
} }
public function test_soh_in_origin()
{
// This packet has a SOH<char>SOH 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);
}
}
} }

Binary file not shown.