From e3d178c24fc66a5574fba829a2d208ca740988ca Mon Sep 17 00:00:00 2001 From: Mario Costa Date: Sat, 23 Oct 2021 23:40:32 -0300 Subject: [PATCH] Prevent exception when using filesystem cache and clients ip as storage key --- src/RateLimitMiddleware.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/RateLimitMiddleware.php b/src/RateLimitMiddleware.php index de2bc74..128fe3e 100644 --- a/src/RateLimitMiddleware.php +++ b/src/RateLimitMiddleware.php @@ -21,6 +21,7 @@ use function explode; use function filter_var; use function is_array; +use function str_replace; use function time; class RateLimitMiddleware implements MiddlewareInterface @@ -72,6 +73,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if (empty($key)) { throw new MissingRequirement('Could not detect the client IP'); } + + $key = str_replace('.', '-', $key); } $data = $this->storage->get($key);