style: Escape quotes and backslashes in turtle rename method for safe Lua string interpolation

This commit is contained in:
MayaTheShy
2026-02-20 02:47:41 -05:00
parent 73f8a21a81
commit c862b2816c

View File

@@ -720,7 +720,9 @@ export class Turtle extends EventEmitter {
* Rename the turtle (set computer label)
*/
async rename(name) {
await this.exec(`os.setComputerLabel("${name}")`);
// Escape quotes and backslashes for safe Lua string interpolation
const safeName = name.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
await this.exec(`os.setComputerLabel("${safeName}")`);
this._label = name;
this._emitUpdate();
}