Attempt to catch invalid FTN addresses while parsing packets

This commit is contained in:
Deon George 2021-12-01 23:41:20 +11:00
parent 3a1c6d55c6
commit bf57f151d5

View File

@ -730,7 +730,11 @@ class Message extends FTNBase
} else {
// Double check, our src and origin match
$this->src = Address::parseFTN($matches[1]);
try {
$this->src = Address::parseFTN($matches[1]);
} catch (\Exception $e) {
Log::error(sprintf('%s:! Origin line address [%s] is invalid [%s]',self::LOGKEY,$this->origin,$e->getMessage()));
}
}
// We'll double check our FTN
@ -819,8 +823,12 @@ class Message extends FTNBase
// http://ftsc.org/docs/fsc-0068.001
// MSGID should be the basis of the source, we'll overrite our src from origin if we have it
$m = [];
if ($this->msgid && preg_match('#([0-9]+:[0-9]+/[0-9]+)?\.?([0-9]+)?@?([A-Za-z-_~]+)?\ +#',$this->msgid,$m)) {
$this->src = Address::parseFTN($m[1].((isset($m[2]) && $m[2] != '') ? '.'.$m[2] : '').(isset($m[3]) ? '@'.$m[3] : ''));
if ($this->msgid && preg_match('#([0-9]+:[0-9]+/[0-9]+)?\.?([0-9]+)?(\.[0-9]+)?@?([A-Za-z-_~]+)?\ +#',$this->msgid,$m)) {
try {
$this->src = Address::parseFTN($m[1].((isset($m[2]) && $m[2] != '') ? '.'.$m[2] : '').(isset($m[4]) ? '@'.$m[4] : ''));
} catch (\Exception $e) {
Log::error(sprintf('%s:! MSGID [%s] address is invalid [%s]',self::LOGKEY,$this->msgid,$e->getMessage()));
}
// Without a MSGID, get our domain from the origin
} elseif ($this->origin && preg_match('#\(([0-9]+:[0-9]+/[0-9]+)?\.?([0-9]+)?@?([A-Za-z-_~]+)?\)$#',$this->origin,$m)) {
@ -830,7 +838,6 @@ class Message extends FTNBase
} elseif ($this->zone) {
$this->src = Address::parseFTN(sprintf('%d:%d/%d.%d@%s',$this->zone->zone_id,$this->fn,$this->ff,$this->fp,$this->zone->domain->name));
}
// Parse SEEN-BY
if ($this->seenby->count())
$this->seenaddress = $this->parseAddresses('seenby',$this->seenby,$this->rogue_seen);