diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-05-03 15:41:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-03 15:41:44 +0100 |
| commit | 21fa9b2ee27227c964fdeb8090d98255edb89bec (patch) | |
| tree | 2027ff3bea1c2a9ac55fd8287aaf67526bb9526b /src/config/lua/bindings/LuaBindingsToplevel.cpp | |
| parent | c0933bffcf0394f7701ab134f6c308eaa9584bee (diff) | |
config/lua: fix dispatcher shapes to not be callable (#14268)
this would only lead to abuse, explicitly forbid it
Diffstat (limited to 'src/config/lua/bindings/LuaBindingsToplevel.cpp')
| -rw-r--r-- | src/config/lua/bindings/LuaBindingsToplevel.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/config/lua/bindings/LuaBindingsToplevel.cpp b/src/config/lua/bindings/LuaBindingsToplevel.cpp index 2d54a7b3..1b345cde 100644 --- a/src/config/lua/bindings/LuaBindingsToplevel.cpp +++ b/src/config/lua/bindings/LuaBindingsToplevel.cpp @@ -132,13 +132,12 @@ static int hlBind(lua_State* L) { if (auto res = parseKeyString(kb, keys); !res) return Internal::configError(L, std::format("hl.bind: failed to parse key string: {}", res.error())); - if (!lua_isfunction(L, 2)) + if (!Internal::pushDispatcherFunction(L, 2)) return Internal::configError(L, "hl.bind: dispatcher must be a dispatcher (e.g. hl.dsp.window.close()) or a lua function"); if (kb.catchAll && mgr->m_currentSubmap.empty()) return Internal::configError(L, "hl.bind: catchall keybinds are only allowed in submaps."); - lua_pushvalue(L, 2); int ref = luaL_ref(L, LUA_REGISTRYINDEX); kb.handler = "__lua"; kb.arg = std::to_string(ref); @@ -293,10 +292,9 @@ static int hlExecCmd(lua_State* L) { } static int hlDispatch(lua_State* L) { - if (!lua_isfunction(L, 1)) - return Internal::configError(L, "hl.dispatch: expected a dispatcher function (e.g. hl.dsp.window.close())"); + if (!Internal::pushDispatcherFunction(L, 1)) + return Internal::configError(L, "hl.dispatch: expected a dispatcher (e.g. hl.dsp.window.close())"); - lua_pushvalue(L, 1); int status = LUA_OK; if (auto* mgr = CConfigManager::fromLuaState(L); mgr) status = mgr->guardedPCall(0, 1, 0, CConfigManager::LUA_TIMEOUT_DISPATCH_MS, "hl.dispatch"); |
