diff --git a/src/Core/Form.php b/src/Core/Form.php index 32e6c4f11e..e674f59870 100644 --- a/src/Core/Form.php +++ b/src/Core/Form.php @@ -33,8 +33,10 @@ declare(strict_types = 1); namespace App\Core; use App\Core\DB\DB; +use function App\Core\I18n\_m; use App\Core\Router\Router; use App\Util\Common; +use App\Util\Exception\ClientException; use App\Util\Exception\RedirectException; use App\Util\Exception\ServerException; use App\Util\Formatting; @@ -45,6 +47,7 @@ use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface as SymfFormInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; /** * This class converts our own form representation to Symfony's @@ -224,11 +227,10 @@ abstract class Form $next = mb_substr($next, 0, $pos); } Router::match($next); - $next = $next . ($fragment ?? ''); return new RedirectResponse(url: $next . ($fragment ?? '')); } catch (ResourceNotFoundException $e) { $user = Common::user(); - $user_id = \is_null($user) ? $user->getId() : '(not logged in)'; + $user_id = !\is_null($user) ? $user->getId() : '(not logged in)'; Log::warning("Suspicious activity: User with ID {$user_id} submitted a form where the `_next` parameter is not a valid local URL ({$next})"); throw new ClientException(_m('Invalid form submission'), $e); }