mcamara / laravel-localization

Easy localization for Laravel
MIT License
3.38k stars 514 forks source link

LocaleCookieRedirect redirect invalid locale #826

Open adriallongarriu opened 2 years ago

adriallongarriu commented 2 years ago

Describe the bug The Middleware LocaleCookieRedirect in line 59 use $params[0] insed of $locale. Variable params are not validate with the funcion checkLocaleInSupportedLocales() this cause to store incorrect values inside cookies.

https://github.com/mcamara/laravel-localization/blob/27565315c585e90d8d93aa06afd49d6a5992fe5a/src/Mcamara/LaravelLocalization/Middleware/LocaleCookieRedirect.php#L59

Expected behavior Ignore $params[0] if is not a supported locale and don't sotre value to cookies.

More info:

mrdoinel commented 1 day ago

I have the same issue with LocaleCookieRedirect specially when used with config :

useAcceptLanguageHeader = true hideDefaultLocaleInURL = true

I am getting stuck in a language because LocaleCookieRedirect.php is incorrectly setting up the wrong cookie when redirecting