From 90ca9407d5b46d220472ceaabb78b62c7ed9b011 Mon Sep 17 00:00:00 2001 From: BrokenName Date: Mon, 27 Dec 2021 10:38:00 -0800 Subject: [PATCH] Update NetscriptFunctions.ts Undid removal of writePort data validation --- src/NetscriptFunctions.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index db4d1a0fe..493aa3181 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1758,6 +1758,12 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { return res; }, writePort: function (port: any, data: any = ""): any { + if (typeof data !== "string" && typeof data !== "number") { + throw makeRuntimeErrorMsg( + "writePort", + `Trying to write invalid data to a port: only strings and numbers are valid.`, + ); + } const iport = helper.getValidPort("writePort", port); return Promise.resolve(iport.write(data)); },