style: Escape quotes and backslashes in turtle rename method for safe Lua string interpolation
This commit is contained in:
@@ -720,7 +720,9 @@ export class Turtle extends EventEmitter {
|
|||||||
* Rename the turtle (set computer label)
|
* Rename the turtle (set computer label)
|
||||||
*/
|
*/
|
||||||
async rename(name) {
|
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._label = name;
|
||||||
this._emitUpdate();
|
this._emitUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user