From c8db709287967670275d5045763391173873f359 Mon Sep 17 00:00:00 2001 From: smolgumball Date: Mon, 10 Jan 2022 21:00:52 -0700 Subject: [PATCH] Add hostname safety --- src/Terminal/commands/ls.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Terminal/commands/ls.tsx b/src/Terminal/commands/ls.tsx index 536af6995..2c00e7f28 100644 --- a/src/Terminal/commands/ls.tsx +++ b/src/Terminal/commands/ls.tsx @@ -120,9 +120,10 @@ export function ls( interface ClickableScriptRowProps { row: string; prefix: string; + hostname: string; } - function ClickableScriptRow({ row, prefix }: ClickableScriptRowProps): React.ReactElement { + function ClickableScriptRow({ row, prefix, hostname }: ClickableScriptRowProps): React.ReactElement { const classes = makeStyles((theme: Theme) => createStyles({ scriptLinksWrap: { @@ -144,6 +145,9 @@ export function ls( .filter((x) => !!x); function onScriptLinkClick(filename: string): void { + if (player.getCurrentServer().hostname !== hostname) { + return terminal.error(`File is not on this server, connect to ${hostname} and try again`); + } if (filename.startsWith("/")) filename = filename.slice(1); const filepath = terminal.getFilepath(`${prefix}${filename}`); const code = toString(terminal.getScript(player, filepath)?.code); @@ -177,7 +181,7 @@ export function ls( terminal.print(row); } else { if (linked) { - terminal.printRaw(); + terminal.printRaw(); } else { terminal.printRaw({row}); }