mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-18 23:03:13 +09:00
Pick a long bracket the json does not close in rcon commands (#506)
exp_reports, exp_roles and exp_groups wrapped the json they send to Lua in a fixed [=[ ]=] long bracket. A report reason, role name or group name containing ]=] closed it early and the rest ran as Lua through /sc. Any player can make a report, so any player could run code on the server. Use the next level the json does not contain, like the other plugins do. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
55bdf72fff
commit
8e7ac3c872
5 files changed
+51
-9
No files matched your search
@@ -14,8 +14,14 @@ export default async function (context: InstancePluginContext) {
|
||||
const syncMode = () => instance.config.get("exp_roles.sync_mode");
|
||||
|
||||
async function luaSend(receiver: string, json: any) {
|
||||
const text = JSON.stringify(json);
|
||||
// Role names and tags can contain anything, so pick a long bracket level the json does not close
|
||||
let level = "=";
|
||||
while (text.includes(`]${level}]`)) {
|
||||
level += "=";
|
||||
}
|
||||
await instance.sendRcon(
|
||||
`/sc exp_roles.${receiver}(helpers.json_to_table[=[${JSON.stringify(json)}]=])`, true
|
||||
`/sc exp_roles.${receiver}(helpers.json_to_table[${level}[${text}]${level}])`, true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user