Skip to content

Commit 31e12e5

Browse files
committed
http/hsts: clean early and often to avoid expired items later
1 parent 91c10f6 commit 31e12e5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

http/hsts.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ function store_methods:store(host, directives)
5050
max_age = tonumber(max_age, 10)
5151
end
5252

53+
-- Clean now so that we can assume there are no expired items in store
54+
self:clean()
55+
5356
if max_age == 0 then
5457
return self:remove(host)
5558
else
@@ -86,14 +89,15 @@ function store_methods:check(host)
8689
if http_util.is_ip(host) then
8790
return false
8891
end
89-
local now = self.time()
92+
93+
-- Clean now so that we can assume there are no expired items in store
94+
self:clean()
95+
9096
local h = host
9197
repeat
9298
local item = self.domains[h]
9399
if item then
94-
if item.expires < now then
95-
self:clean()
96-
elseif host == h or item.includeSubdomains then
100+
if host == h or item.includeSubdomains then
97101
return true
98102
end
99103
end

0 commit comments

Comments
 (0)