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;
|
namespace App\Classes\FTN;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@ -10,7 +11,7 @@ use Illuminate\Support\Facades\Validator;
|
|||||||
use Illuminate\Validation\Validator as ValidatorResult;
|
use Illuminate\Validation\Validator as ValidatorResult;
|
||||||
|
|
||||||
use App\Classes\FTN as FTNBase;
|
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\Rules\{TwoByteInteger,TwoByteIntegerWithZero};
|
||||||
use App\Traits\EncodeUTF8;
|
use App\Traits\EncodeUTF8;
|
||||||
|
|
||||||
@ -273,12 +274,15 @@ class Message extends FTNBase
|
|||||||
|
|
||||||
case 'date':
|
case 'date':
|
||||||
try {
|
try {
|
||||||
return Carbon::createFromFormat('d M y H:i:s O',
|
if (str_contains($x=chop(Arr::get($this->header,$key)),"\x00"))
|
||||||
sprintf('%s %s%04d',chop(Arr::get($this->header,$key)),($this->tzutc < 0) ? '-' : '+',abs($this->tzutc)));
|
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)));
|
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':
|
case 'flags':
|
||||||
|
Loading…
Reference in New Issue
Block a user