Skip to content

Commit

Permalink
Remove non-printable characters from websocket reads
Browse files Browse the repository at this point in the history
  • Loading branch information
MurrayGroves authored Feb 8, 2023
1 parent 1645101 commit 7a931d1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,8 @@ async def incoming(websocket, path):
ciphertext, tag, nonce = base64.b64decode(ciphertext.encode("utf-8")), base64.b64decode(tag.encode("utf-8")), base64.b64decode(nonce.encode("utf-8"))
cipher_aes = AES.new(session_key, AES.MODE_GCM, nonce)
plaintext = cipher_aes.decrypt_and_verify(ciphertext, tag)
data = plaintext.decode("ascii", errors="ignore")
data = plaintext.decode("utf-8")
data = ''.join(c for c in data if c.isprintable())
logging.debug(repr(data))

except Exception as e:
Expand Down

0 comments on commit 7a931d1

Please sign in to comment.