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

[6.x] Fix rate limiting unicode issue #39375

Merged
merged 2 commits into from
Oct 26, 2021
Merged

Conversation

driesvints
Copy link
Member

This PR fixes an issue where rate limiting would be reset for characters with unicode in them. By converting these characters to regular ones, the same key is re-used and rate limiting is properly applied, albeit a bit stricter.

@driesvints driesvints changed the title Fix rate limiting unicode issue [6.x] Fix rate limiting unicode issue Oct 26, 2021
@driesvints driesvints marked this pull request as ready for review October 26, 2021 19:18
@taylorotwell taylorotwell merged commit a59bdb8 into 6.x Oct 26, 2021
@taylorotwell taylorotwell deleted the fix-rate-limiting-unicode-issue branch October 26, 2021 19:50
@oliworx
Copy link

oliworx commented Nov 3, 2021

This fix will not work as intendet with most of the unicode characters.
The test covers only one simple example from a roman language.

Lets assume a key with CJK characters like 'ユニコード' :

>>> $key = 'ユニコード';
>>> preg_replace('/&([a-z])[a-z]+;/i', '$1', htmlentities($key));
=> "ユニコード"

So the unicode string is not modified at all.

@driesvints
Copy link
Member Author

@oliworx that's not an issue. This fix was purely focused on alphabetic characters which were non-unique for a DB store but unique for the limiter. Other unicode characters have no direct alphabetic replacements and are always unique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants