From 658139771dffb486ae4887038a76ad691ca1b153 Mon Sep 17 00:00:00 2001 From: the lemons Date: Mon, 7 Feb 2022 15:02:40 -0600 Subject: permit a wider range of values with #set --- zzcxz.cgi | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/zzcxz.cgi b/zzcxz.cgi index c6c8de4..c7ec545 100755 --- a/zzcxz.cgi +++ b/zzcxz.cgi @@ -165,15 +165,12 @@ local function parse_directive(line, directives) directives.redirect = redirect elseif directive == "set" then if args:match "^%s*$" then return end - local flagname = args:match "^%s*(%w+)%s*$" - local text = "" - if not flagname then - flagname, text = args:match "^%s*(%w+)%s*(%w+)%s*$" - if not flagname or not text or utf8.len(text) > 1000 then - return - end + local flagname, text = args:match "^%s*(%w+)%s*(.-)%s*$" + if not flagname then return end + text = text or "" + if utf8.len(flagname) > 150 or utf8.len(text) > 1000 then + return end - if utf8.len(flagname) > 150 then return end directives.flags_updated[flagname] = text flags[flagname] = text elseif directive == "unset" then @@ -350,7 +347,7 @@ map["^/g/(%w%w%w%w%w)$"] = function(p) for flagname, text in pairs(directives.flags_updated) do if text then table.insert(cookies, - ('flag_%s=%s; secure; max-age=999999999999') + ('flag_%s=%s; max-age=999999999999') :format(flagname, url_encode(text))) else -- clear the cookie by expiring it in the past -- cgit v1.2.3