Template
1
0
mirror of https://github.com/bol-van/zapret2.git synced 2026-03-14 06:13:09 +00:00

nfqws2, zapret-lib: always treat blobs, % and # as string

This commit is contained in:
bol-van
2026-02-17 19:21:44 +03:00
parent 5ced6811c8
commit 1b1c8ddb38
2 changed files with 7 additions and 2 deletions

View File

@@ -153,7 +153,7 @@ function apply_arg_prefix(desync)
local c = string.sub(v,1,1) local c = string.sub(v,1,1)
if c=='#' then if c=='#' then
local blb = blob(desync,string.sub(v,2)) local blb = blob(desync,string.sub(v,2))
desync.arg[a] = (type(blb)=='string' or type(blb)=='table') and #blb or 0 desync.arg[a] = tostring((type(blb)=='string' or type(blb)=='table') and #blb or 0)
elseif c=='%' then elseif c=='%' then
desync.arg[a] = blob(desync,string.sub(v,2)) desync.arg[a] = blob(desync,string.sub(v,2))
elseif c=='\\' then elseif c=='\\' then
@@ -545,6 +545,7 @@ function blob(desync, name, def)
error("blob '"..name.."' unavailable") error("blob '"..name.."' unavailable")
end end
end end
blob = tostring(blob)
end end
return blob return blob
end end

View File

@@ -1248,6 +1248,7 @@ void lua_push_blob(lua_State *L, int idx_desync, const char *blob)
lua_pop(L,1); lua_pop(L,1);
lua_getglobal(L, blob); lua_getglobal(L, blob);
} }
lua_tostring(L,-1);
} }
void lua_pushf_blob(lua_State *L, int idx_desync, const char *field, const char *blob) void lua_pushf_blob(lua_State *L, int idx_desync, const char *field, const char *blob)
{ {
@@ -1779,7 +1780,10 @@ void lua_pushf_args(lua_State *L, const struct str2_list_head *args, int idx_des
lua_push_blob(L, idx_desync, val+1); lua_push_blob(L, idx_desync, val+1);
lua_Integer len = lua_rawlen(L, -1); lua_Integer len = lua_rawlen(L, -1);
lua_pop(L,1); lua_pop(L,1);
lua_pushf_int(L, var, len); lua_pushstring(L, var);
lua_pushinteger(L, len);
lua_tostring(L,-1); // force string type in arg
lua_rawset(L,-3);
} }
else else
lua_pushf_str(L, var, val); lua_pushf_str(L, var, val);