mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +00:00
fix: additional checks for tag set/get
This commit is contained in:
parent
c1a91d4dec
commit
ef36ea6999
1 changed files with 8 additions and 1 deletions
|
@ -6,6 +6,9 @@ import { findTagByName } from "./findTagByName";
|
|||
|
||||
const MAX_TAG_FN_CALLS = 25;
|
||||
|
||||
// This is used to disallow setting/getting default object properties (such as __proto__) in dynamicVars
|
||||
const emptyObject = {};
|
||||
|
||||
export async function renderTagBody(
|
||||
pluginData: GuildPluginData<TagsPluginType>,
|
||||
body: TTag,
|
||||
|
@ -22,15 +25,19 @@ export async function renderTagBody(
|
|||
...pluginData.state.tagFunctions,
|
||||
set(name, val) {
|
||||
if (typeof name !== "string") return;
|
||||
if (emptyObject[name]) return;
|
||||
dynamicVars[name] = val;
|
||||
},
|
||||
setr(name, val) {
|
||||
if (typeof name !== "string") return "";
|
||||
if (emptyObject[name]) return;
|
||||
dynamicVars[name] = val;
|
||||
return val;
|
||||
},
|
||||
get(name) {
|
||||
return !dynamicVars.hasOwnProperty(name) || dynamicVars[name] == null ? "" : dynamicVars[name];
|
||||
if (typeof name !== "string") return "";
|
||||
if (emptyObject[name]) return;
|
||||
return !Object.hasOwn(dynamicVars, name) || dynamicVars[name] == null ? "" : dynamicVars[name];
|
||||
},
|
||||
tag: async (name, ...subTagArgs) => {
|
||||
if (++tagFnCallsObj.calls > MAX_TAG_FN_CALLS) return "";
|
||||
|
|
Loading…
Add table
Reference in a new issue