diff options
Diffstat (limited to 'zzcxz.cgi')
-rwxr-xr-x | zzcxz.cgi | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -176,6 +176,11 @@ local function parse_directive(line, directives) if utf8.len(flagname) > 150 then return end directives.flags_updated[flagname] = text flags[flagname] = text + elseif directive == "unset" then + local flagname = args:match "^%s*(%w+)%s*$" + if not flagname then return end + directives.flags_updated[flagname] = false + flags[flagname] = nil else return end @@ -343,9 +348,16 @@ map["^/g/(%w%w%w%w%w)$"] = function(p) local cookies = {} for flagname, text in pairs(directives.flags_updated) do - table.insert(cookies, - ('flag_%s=%s; Secure; Max-Age=999999999') - :format(flagname, url_encode(text))) + if text then + table.insert(cookies, + ('flag_%s=%s; secure; max-age=999999999999') + :format(flagname, url_encode(text))) + else + -- clear the cookie by expiring it in the past + table.insert(cookies, + ('flag_%s=; expires=Thu, 01 Jan 1970 00:00:00 GMT;') + :format(flagname)) + end end return base { |