mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-16 08:24:52 +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
@@ -29,7 +29,13 @@ export default async function (context: InstancePluginContext) {
|
||||
const onlinePlayers = new Set<string>();
|
||||
|
||||
async function luaSend(receiver: string, json: any) {
|
||||
await instance.sendRcon(`/sc exp_groups.${receiver}(helpers.json_to_table[=[${JSON.stringify(json)}]=])`, true)
|
||||
const text = JSON.stringify(json);
|
||||
// Group names 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_groups.${receiver}(helpers.json_to_table[${level}[${text}]${level}])`, true)
|
||||
}
|
||||
|
||||
async function updatePlayerAssignmentSubscription(playerName: string, action: "subscribe" | "unsubscribe") {
|
||||
|
||||
Reference in new issue
Block a user