2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

FIX: RateLimiter max of zero or less should raise rate limit exceeded.

This commit is contained in:
Guo Xiang Tan 2018-03-01 13:12:31 +08:00
parent 47c41f474d
commit 5d9f9c2614
2 changed files with 12 additions and 1 deletions

View file

@ -83,7 +83,7 @@ class RateLimiter
def performed!
return if rate_unlimited?
now = Time.now.to_i
if eval_lua(PERFORM_LUA, PERFORM_LUA_SHA, [prefixed_key], [now, @secs, @max]) == 0
if max <= 0 || (eval_lua(PERFORM_LUA, PERFORM_LUA_SHA, [prefixed_key], [now, @secs, @max]) == 0)
raise RateLimiter::LimitExceeded.new(seconds_to_wait, @type)
end
rescue Redis::CommandError => e