Fix for when packets have a kludge after the origin line, and now capturing taglines. Updated testing configuration
This commit is contained in:
parent
fb65c645cb
commit
c8a2affbfa
@ -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=
|
||||
|
18
.env.testing
18
.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=
|
||||
|
@ -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))
|
||||
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.
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
21
phpunit.xml
21
phpunit.xml
@ -1,14 +1,22 @@
|
||||
<?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"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
<directory>tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
<directory>tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage/>
|
||||
<source>
|
||||
<include>
|
||||
<directory>app</directory>
|
||||
</include>
|
||||
</source>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
@ -20,9 +28,4 @@
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
</php>
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</include>
|
||||
</source>
|
||||
</phpunit>
|
||||
|
@ -119,6 +119,14 @@
|
||||
</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())
|
||||
<div class="row pb-2">
|
||||
<div class="col-8">
|
||||
|
@ -201,4 +201,55 @@ class PacketTest extends TestCase
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
tests/Feature/data/test_msg_with_soh_in_origin.pkt
Normal file
BIN
tests/Feature/data/test_msg_with_soh_in_origin.pkt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user