8000 [RateLimiter] Adding default empty string value on Security::LAST_USERNAME by David-Crty · Pull Request #45948 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RateLimiter] Adding default empty string value on Security::LAST_USERNAME #45948

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

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[RateLimiter] Adding default empty value
Because Security::LAST_USERNAME not always exist, it can trigger a "preg_match(): Argument #2 ($subject) must be of type string" if $username is null
  • Loading branch information
David-Crty authored Apr 5, 2022
commit 0fdfcae49991f62097de59fb8e61a079b2135815
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(RateLimiterFactory $globalFactory, RateLimiterFactor

protected function getLimiters(Request $request): array
{
$username = $request->attributes->get(Security::LAST_USERNAME);
$username = $request->attributes->get(Security::LAST_USERNAME, '');
$username = preg_match('//u', $username) ? mb_strtolower($username, 'UTF-8') : strtolower($username);

return [
Expand Down
0