Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(l10n): Remove URL-based localized routes, store locale in session #587

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

doobry-systemli
Copy link
Contributor

@doobry-systemli doobry-systemli commented Mar 29, 2024

If no locale is set yet, use the browser locale (if supported, fallback to default 'en').

If locale is already set in session, use that one.

If locale is given in query string (parameter _locale), use that locale (if supported, fallback to default 'en').

@doobry-systemli doobry-systemli added the enhancement New feature or request label Mar 29, 2024
if (!$request->attributes->get('_locale')) {
$preferredLanguage = $request->getPreferredLanguage($this->supportedLocales);
$locale = $preferredLanguage ?: $this->defaultLocale;
$event->setResponse(new RedirectResponse('/' . $locale . $request->getPathInfo()));

Check failure

Code scanning / SonarCloud

HTTP request redirections should not be open to forging attacks

<!--SONAR_ISSUE_KEY:AY6KSBvA9cskbWm-zmE_-->Change this code to not perform redirects based on user-controlled data. <p>See more on <a href="https://sonarcloud.io/project/issues?id=systemli_userli&issues=AY6KSBvA9cskbWm-zmE_&open=AY6KSBvA9cskbWm-zmE_&pullRequest=587">SonarCloud</a></p>
If no locale is set yet, use the browser locale (if supported, fallback
to default 'en').

If locale is already set in session, use that one.

If locale is given in query string (parameter `_locale`), use that
locale (if supported, fallback to default 'en').
@doobry-systemli doobry-systemli changed the title feat(l10n): Redirect routes without locale using a LocaleListener feat(l10n): Remove URL-based localized routes, store locale in session Mar 29, 2024
@0x46616c6b 0x46616c6b force-pushed the feat/locale_listener branch from 494e293 to 5d17d6f Compare March 29, 2024 17:55
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
25.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@doobry-systemli doobry-systemli merged commit 6265691 into main Mar 29, 2024
15 of 16 checks passed
@doobry-systemli doobry-systemli deleted the feat/locale_listener branch March 29, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants