diff --git a/server/executor.py b/server/executor.py index b28379d..5c67947 100644 --- a/server/executor.py +++ b/server/executor.py @@ -72,11 +72,14 @@ class Executor: f.close() return currenctfile - def getFileInCurrentDirectory(self, file: str): + def getFileInCurrentDirectory(self, file: str) -> bytes: file = self.sanitizeFile(file) currentfile = os.path.join(self.currentDirectory, file) if os.path.exists(currentfile): - return open(currentfile, "r") + f = open(currentfile, "rb") + content = f.read() + f.close() + return content else: raise Exception('File not found') diff --git a/server/netwrapper.py b/server/netwrapper.py index 4eca973..11aa462 100644 --- a/server/netwrapper.py +++ b/server/netwrapper.py @@ -140,3 +140,4 @@ class NetWrapper: return plaintext except Exception: print("Incorrect decryption") + return "ERROR".encode('UTF-8') diff --git a/server/server.py b/server/server.py index c1f8a28..f2b6cba 100644 --- a/server/server.py +++ b/server/server.py @@ -40,6 +40,8 @@ class Server: self.networkInstance.sendMessage("LINOK".encode('UTF-8')) elif command == "LINERROR": self.networkInstance.sendMessage("LINERROR".encode('UTF-8')) + elif command == "ERROR": + return None parsedCommand = command.split(" ") if len(parsedCommand) > 3: self.networkInstance.sendMessage("ERROR".encode('UTF-8'))