Dont abort a session when there is an invalid FTN presented

This commit is contained in:
2023-09-18 21:22:21 +10:00
parent eb40f94e37
commit 4343774079
4 changed files with 36 additions and 16 deletions

View File

@@ -9,6 +9,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\{Message,Packet};
use App\Exceptions\InvalidFTNException;
use App\Http\Controllers\DomainController;
use App\Traits\ScopeActive;
@@ -821,16 +822,16 @@ class Address extends Model
public static function parseFTN(string $ftn): array
{
if (! preg_match(sprintf('#^%s$#',self::ftn_regex),strtolower($ftn),$matches))
throw new \Exception('Invalid FTN: '.$ftn);
throw new InvalidFTNException(sprintf('Invalid FTN: %s - regex failed',$ftn));
// Check our numbers are correct.
foreach ([1,2,3] as $i) {
if ((! is_numeric($matches[$i])) || ($matches[$i] > DomainController::NUMBER_MAX))
throw new \Exception('Invalid FTN: '.$ftn);
throw new InvalidFTNException(sprintf('Invalid FTN: %s - zone, host or node address invalid',$ftn));
}
if (isset($matches[5]) AND ((! is_numeric($matches[$i])) || ($matches[5] > DomainController::NUMBER_MAX)))
throw new \Exception('Invalid FTN: '.$ftn);
throw new InvalidFTNException(sprintf('Invalid FTN: %s - point address invalid',$ftn));
return [
'z'=>(int)$matches[1],