PassTheMayo / minecraft-server-util

A Node.js library for Minecraft servers that can retrieve status, query, RCON, and send Votifier votes.
https://passthemayo.gitbook.io/minecraft-server-util/
MIT License
141 stars 24 forks source link

bug: Accent seems to reduce command size from one #56

Closed dadodasyra closed 3 years ago

dadodasyra commented 3 years ago

Describe the bug: When you send an accent like 'é', 'è' or 'à' it seems to broke the calculation of the string size and you send the command by removing the last character. (Bedrock only ?)

Code:

let reason = args.join(" "); //I only put the code where I touch to reason which is the command sended
if(reason === "help") return message.reply("La commande help est bloquée car elle cause des soucis");

rconfunc(port, reason, message, serverbase);

function rconfunc(port, reason, message, server)
{
    const rcon = new mcutil.RCON(hidden.rcon.host, { port: port, enableSRV: false, timeout: 5000, password: hidden.rcon.password});
    rcon.connect()
        .then(() => rcon.run(reason))
        .catch((error) => {message.channel.send("Erreur sur la connexion : "+error); console.error(error)});
    rcon.on('output', (out) => {
        if(out && out.length > 1900) out = "\nLa réponse est trop longue";
        else if (!out) out = "Pas de réponse";
        message.reply({
            embeds: [{
                title: `RCON sur **${server}**`,
                color: config.color,
                timestamp: new Date(),
                footer: {
                    icon_url: config.image_url,
                    text: "@Histeria "+new Date().getFullYear()
                },
                fields: [
                    {
                        name: 'Requête',
                        value: String(reason),
                        inline: true
                    },
                    {
                        name: 'Réponse',
                        value: String(out),
                        inline: true
                    }
                ]
            }]
        })
        rcon.close();
    });
}

Expected behavior: Normally the command should be whole (note that if I add an additional character the command works since it is the additional character that is deleted).

Additional context Example in screenshots, image

image image works with any character.

Btw you can add multiple accent to reduce from two for example: image image

PassTheMayo commented 3 years ago

I was able to reproduce this bug locally and determined that it is how JavaScript is calculating string length for the RCON client. I just published a fix, so please update to 3.6.1 and let me know if the bug still exists for you.