Fix packets with null values in the date, and exceptions not catching it
This commit is contained in:
parent
4fe2e35d78
commit
9a8ee1aa2b
@ -3,6 +3,7 @@
|
||||
namespace App\Classes\FTN;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@ -10,7 +11,7 @@ use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Validator as ValidatorResult;
|
||||
|
||||
use App\Classes\FTN as FTNBase;
|
||||
use App\Models\{Address,Domain,Setup,Zone};
|
||||
use App\Models\{Address,Domain,Zone};
|
||||
use App\Rules\{TwoByteInteger,TwoByteIntegerWithZero};
|
||||
use App\Traits\EncodeUTF8;
|
||||
|
||||
@ -273,12 +274,15 @@ class Message extends FTNBase
|
||||
|
||||
case 'date':
|
||||
try {
|
||||
return Carbon::createFromFormat('d M y H:i:s O',
|
||||
sprintf('%s %s%04d',chop(Arr::get($this->header,$key)),($this->tzutc < 0) ? '-' : '+',abs($this->tzutc)));
|
||||
if (str_contains($x=chop(Arr::get($this->header,$key)),"\x00"))
|
||||
throw new \Exception('Date contains null values.');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return Carbon::createFromFormat('d M y H:i:s O',
|
||||
sprintf('%s %s%04d',$x,($this->tzutc < 0) ? '-' : '+',abs($this->tzutc)));
|
||||
|
||||
} catch (InvalidFormatException|\Exception $e) {
|
||||
Log::error(sprintf('%s: ! Date doesnt parse [%s] (%s)',self::LOGKEY,$e->getMessage(),Arr::get($this->header,$key)));
|
||||
return NULL;
|
||||
throw new \Exception($e->getMessage());
|
||||
}
|
||||
|
||||
case 'flags':
|
||||
|
Loading…
Reference in New Issue
Block a user