diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 4812dbaceb..ede386128b 100755 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -18,7 +18,7 @@ use Illuminate\Auth\AuthenticationException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Session\TokenMismatchException; -use Illuminate\Validation\ValidationException; +use Illuminate\Validation\ValidationException as ValException; use Symfony\Component\HttpKernel\Exception\HttpException; /** @@ -40,7 +40,7 @@ class Handler extends ExceptionHandler HttpException::class, ModelNotFoundException::class, TokenMismatchException::class, - ValidationException::class, + ValException::class, ]; /** diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php index 25305f4dd5..cbb6656967 100644 --- a/app/Helpers/Attachments/AttachmentHelper.php +++ b/app/Helpers/Attachments/AttachmentHelper.php @@ -59,7 +59,7 @@ class AttachmentHelper implements AttachmentHelperInterface */ public function getAttachmentLocation(Attachment $attachment): string { - $path = storage_path('upload') . DIRECTORY_SEPARATOR . 'at-' . $attachment->id . '.data'; + $path = sprintf('%s%sat-%d.data', storage_path('upload'), DIRECTORY_SEPARATOR, $attachment->id); return $path; } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 36ee3b4b88..46a4bedf9a 100755 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -28,6 +28,7 @@ class ForgotPasswordController extends Controller */ public function __construct() { + parent::__construct(); $this->middleware('guest'); } } diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 67bd567b85..7024bf46b8 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -421,6 +421,7 @@ class ImportController extends Controller { // create proper importer (depends on job) $type = $job->file_type; + /** @var SetupInterface $importer */ $importer = app('FireflyIII\Import\Setup\\' . ucfirst($type) . 'Setup'); $importer->setJob($job); diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 7673602135..85b16c7dc0 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -226,7 +226,7 @@ class TagController extends Controller $subTitle = $tag->tag; $subTitleIcon = 'fa-tag'; - // TODO move to repository. + /** @var Collection $journals */ $journals = $tag diff --git a/app/Import/Importer/CsvImporter.php b/app/Import/Importer/CsvImporter.php index 558ac4fa6f..e377b9baa7 100644 --- a/app/Import/Importer/CsvImporter.php +++ b/app/Import/Importer/CsvImporter.php @@ -124,8 +124,9 @@ class CsvImporter implements ImporterInterface $doMap = $config['column-do-mapping'][$rowIndex] ?? false; $converterClass = config('csv.import_roles.' . $role . '.converter'); $mapping = $config['column-mapping-config'][$rowIndex] ?? []; + $className = sprintf('FireflyIII\\Import\\Converter\\%s', $converterClass); /** @var ConverterInterface $converter */ - $converter = app('FireflyIII\\Import\\Converter\\' . $converterClass); + $converter = app($className); // set some useful values for the converter: $converter->setMapping($mapping); $converter->setDoMap($doMap); diff --git a/app/Import/Setup/CsvSetup.php b/app/Import/Setup/CsvSetup.php index 1cc57bca9a..e5f6e6ca6f 100644 --- a/app/Import/Setup/CsvSetup.php +++ b/app/Import/Setup/CsvSetup.php @@ -216,7 +216,11 @@ class CsvSetup implements SetupInterface // loop specifics. if (isset($data['specifics']) && is_array($data['specifics'])) { foreach ($data['specifics'] as $name => $enabled) { - $config['specifics'][$name] = 1; + // verify their content. + $className = sprintf('FireflyIII\Import\Specifics\%s', $name); + if (class_exists($className)) { + $config['specifics'][$name] = 1; + } } } $this->job->configuration = $config; diff --git a/app/Repositories/ImportJob/ImportJobRepository.php b/app/Repositories/ImportJob/ImportJobRepository.php index edbfb2ec97..fbf6e67eda 100644 --- a/app/Repositories/ImportJob/ImportJobRepository.php +++ b/app/Repositories/ImportJob/ImportJobRepository.php @@ -11,6 +11,7 @@ declare(strict_types = 1); namespace FireflyIII\Repositories\ImportJob; +use FireflyIII\Exceptions\FireflyException; use FireflyIII\Models\ImportJob; use FireflyIII\User; use Illuminate\Support\Str; @@ -42,7 +43,13 @@ class ImportJobRepository implements ImportJobRepositoryInterface */ public function create(string $fileType): ImportJob { - $count = 0; + $count = 0; + $fileType = strtolower($fileType); + $keys = array_keys(config('firefly.import_formats')); + if (!in_array($fileType, $keys)) { + throw new FireflyException(sprintf('Cannot use type "%s" for import job.', $fileType)); + } + while ($count < 30) { $key = Str::random(12); $existing = $this->findByKey($key); diff --git a/routes/web.php b/routes/web.php index b02db29f73..c613156818 100755 --- a/routes/web.php +++ b/routes/web.php @@ -17,18 +17,18 @@ Route::group( ['middleware' => 'user-not-logged-in'], function () { // Authentication Routes... - Route::get('login', 'Auth\LoginController@showLoginForm')->name('login'); # - Route::post('login', 'Auth\LoginController@login'); # + Route::get('login', 'Auth\LoginController@showLoginForm')->name('login'); + Route::post('login', 'Auth\LoginController@login'); // Registration Routes... - Route::get('/register', ['uses' => 'Auth\RegisterController@showRegistrationForm', 'as' => 'register']); # - Route::post('/register', 'Auth\RegisterController@register'); # + Route::get('/register', ['uses' => 'Auth\RegisterController@showRegistrationForm', 'as' => 'register']); + Route::post('/register', 'Auth\RegisterController@register'); // Password Reset Routes... - Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm'); # - Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail'); # - Route::post('/password/reset', 'Auth\ResetPasswordController@reset'); # - Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm'); # + Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm'); + Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail'); + Route::post('/password/reset', 'Auth\ResetPasswordController@reset'); + Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm'); }