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:
BastiaanandClaude Opus 5.5 authored and GitHub committed 2026-10-15 17:07:47 +01:00
1 parent 55bdf72fff
commit 8e7ac3c872
5 files changed
+51 -9

No files matched your search

+7 -1
View File
@@ -36,8 +36,14 @@ export default async function (context: InstancePluginContext) {
if (instance.status !== "running") {
return;
}
const text = JSON.stringify(json);
// Reasons 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_reports.${receiver}(helpers.json_to_table[=[${JSON.stringify(json)}]=])`, true
`/sc exp_reports.${receiver}(helpers.json_to_table[${level}[${text}]${level}])`, true
);
}