Skip to content

Conversation

@Seldaek
Copy link
Member

@Seldaek Seldaek commented May 11, 2021

Q A
Branch? 5.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

As per discussion in #41156

@derrabus derrabus added this to the 5.2 milestone May 11, 2021
return [
$this->globalFactory->create($request->getClientIp()),
$this->localFactory->create(strtolower($request->attributes->get(Security::LAST_USERNAME)).'-'.$request->getClientIp()),
$this->localFactory->create(mb_strtolower($request->attributes->get(Security::LAST_USERNAME)).'-'.$request->getClientIp()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not rely on the global php.ini config
this should instead be:
\function_exists('mb_strtolower') && preg_match('//u', $v) ? mb_strtolower($v, 'UTF-8') : strtolower($v);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need function_exists('mb_strtolower')? The polyfill should make sure that the method exists, shouldn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@derrabus that's my understanding too.

@nicolas-grekas are you sure about passing 'UTF-8'? I don't mind changing, but seeing as utf-8 has been the default for a while, and if someone explicitly sets it to something else I'd assume they have a good reason and maybe it makes sense to follow their setting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, about function_exists
for the ini setting, I think the code base is decoupled from it and we always use that kind of calls.
no global state rulez :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok done.. I kept the preg_match() guard, not sure if it's really needed or not? Is the polyfill not enough?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed yes :)

@nicolas-grekas nicolas-grekas changed the title [Security] Make Login Rate Limiter also case insensitive for non-asci… [Security] Make Login Rate Limiter also case insensitive for non-ascii user identifiers May 11, 2021
@derrabus
Copy link
Member

Thank you Jordi.

@derrabus derrabus merged commit 3348c63 into symfony:5.2 May 11, 2021
This was referenced May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants