From 65be9f438bc11902c8357bbe86a9a86ac60f3f81 Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 31 Mar 2019 14:05:15 -0400 Subject: [PATCH 1/2] CryptMessage: pass byte-array type to base64 Fixes this error upon sending a message in ZeroMail: WebSocket handleRequest error: TypeError: a bytes-like object is required, not 'str' in UiWebsocket.py line 83 > UiWebsocket.py line 269 > CryptMessage/CryptMessagePlugin.py line 80 > CryptMessage/CryptMessagePlugin.py line 80 > base64.py line 58 --- plugins/CryptMessage/CryptMessagePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/CryptMessage/CryptMessagePlugin.py b/plugins/CryptMessage/CryptMessagePlugin.py index 50b69003..fb895975 100644 --- a/plugins/CryptMessage/CryptMessagePlugin.py +++ b/plugins/CryptMessage/CryptMessagePlugin.py @@ -75,7 +75,7 @@ class UiWebsocketPlugin(object): if text: encrypted = pyelliptic.Cipher(key, iv, 1, ciphername='aes-256-cbc').ciphering(text.encode("utf8")) else: - encrypted = "" + encrypted = b"" res = [base64.b64encode(item).decode("utf8") for item in [key, iv, encrypted]] self.response(to, res) From 941571f71f6c75b1ebcb0c75c6987b76cc47df16 Mon Sep 17 00:00:00 2001 From: redfish Date: Sun, 31 Mar 2019 16:25:26 -0400 Subject: [PATCH 2/2] file: set error message before using it Fixes this exception: Unhandled exception: [(, UnboundLocalError("local variable 'err' referenced before assignm> Traceback (most recent call last): File "src/gevent/greenlet.py", line 766, in gevent._greenlet.Greenlet.run File "/opt/zeronet/src/util/RateLimit.py", line 57, in thread = gevent.spawn_later(time_left, lambda: callQueue(event)) # Call this function later File "/opt/zeronet/src/util/RateLimit.py", line 42, in callQueue return func(*args, **kwargs) File "/opt/zeronet/src/File/FileRequest.py", line 185, in actionUpdate self.response({"error": "File invalid: %s" % err}) UnboundLocalError: local variable 'err' referenced before assignment --- src/File/FileRequest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/File/FileRequest.py b/src/File/FileRequest.py index f316c5f2..98bda0ca 100644 --- a/src/File/FileRequest.py +++ b/src/File/FileRequest.py @@ -133,6 +133,7 @@ class FileRequest(object): valid = site.content_manager.verifyFile(inner_path, content) except Exception as err: self.log.debug("Update for %s is invalid: %s" % (inner_path, err)) + error = err valid = False if valid is True: # Valid and changed @@ -182,7 +183,7 @@ class FileRequest(object): self.connection.badAction() else: # Invalid sign or sha hash - self.response({"error": "File invalid: %s" % err}) + self.response({"error": "File %s invalid: %s" % (inner_path, error)}) self.connection.badAction(5) def isReadable(self, site, inner_path, file, pos):