Add basic catch for big date ranges.

This commit is contained in:
James Cole 2023-12-27 15:48:04 +01:00
parent 636b3921fa
commit 609edb9dff
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80

View File

@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Data;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
@ -43,9 +44,15 @@ class DateRequest extends FormRequest
*/
public function getAll(): array
{
$start = $this->getCarbonDate('start');
$end = $this->getCarbonDate('end');
if($start->diffInYears($end) > 5) {
throw new FireflyException('Date range out of range.');
}
return [
'start' => $this->getCarbonDate('start'),
'end' => $this->getCarbonDate('end'),
'start' => $start,
'end' => $end,
];
}