diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2018-10-13 09:24:39 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2018-10-13 09:39:00 +0200 |
commit | 4d4147b228ac90f329fd2d40dd4fb60cb980328a (patch) | |
tree | bb18d67c8ec03bf8abd24dc6ef2138c3f81f6fa5 /src/Wallabag/CoreBundle/Controller | |
parent | be417ef23685e17a239b1d192a0e9b9f484f1bfe (diff) | |
download | wallabag-4d4147b228ac90f329fd2d40dd4fb60cb980328a.tar.gz wallabag-4d4147b228ac90f329fd2d40dd4fb60cb980328a.tar.zst wallabag-4d4147b228ac90f329fd2d40dd4fb60cb980328a.zip |
Ensure language is valid
- Do not override locale if user has choosen a locale from the login screen.
- Add some tests about locale url
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 99576fbb..be6feb7c 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; | |||
8 | use Symfony\Component\HttpFoundation\Request; | 8 | use Symfony\Component\HttpFoundation\Request; |
9 | use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | 9 | use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; |
10 | use Symfony\Component\Routing\Annotation\Route; | 10 | use Symfony\Component\Routing\Annotation\Route; |
11 | use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint; | ||
11 | use Wallabag\CoreBundle\Entity\Config; | 12 | use Wallabag\CoreBundle\Entity\Config; |
12 | use Wallabag\CoreBundle\Entity\TaggingRule; | 13 | use Wallabag\CoreBundle\Entity\TaggingRule; |
13 | use Wallabag\CoreBundle\Form\Type\ChangePasswordType; | 14 | use Wallabag\CoreBundle\Form\Type\ChangePasswordType; |
@@ -341,11 +342,13 @@ class ConfigController extends Controller | |||
341 | */ | 342 | */ |
342 | public function setLocaleAction(Request $request, $language = null) | 343 | public function setLocaleAction(Request $request, $language = null) |
343 | { | 344 | { |
344 | if (null !== $language) { | 345 | $errors = $this->get('validator')->validate($language, (new LocaleConstraint())); |
345 | $this->get('session')->set('_locale', $language); | 346 | |
347 | if (0 === \count($errors)) { | ||
348 | $request->getSession()->set('_locale', $language); | ||
346 | } | 349 | } |
347 | 350 | ||
348 | return $this->redirect($request->headers->get('referer')); | 351 | return $this->redirect($request->headers->get('referer', $this->generateUrl('homepage'))); |
349 | } | 352 | } |
350 | 353 | ||
351 | /** | 354 | /** |