From 8aea956e77947976799ea7db1f4fa1aa4c915190 Mon Sep 17 00:00:00 2001 From: r4sas Date: Mon, 24 Jun 2019 01:18:27 +0000 Subject: [PATCH] Update function in map iterator Fixes #14. Thanks to @mqus for solution. Taken from https://github.com/PrivateBin/PrivateBin/pull/193#issuecomment-480262590 --- pbincli/format.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pbincli/format.py b/pbincli/format.py index 5f674ed..7d0686e 100644 --- a/pbincli/format.py +++ b/pbincli/format.py @@ -141,7 +141,7 @@ class Paste: # nothing to do, just return original data return s elif self._version == 1: - return zlib.decompress(bytearray(map(ord, b64decode(s.encode('utf-8')).decode('utf-8'))), -zlib.MAX_WBITS) + return zlib.decompress(bytearray(map(lambda c:ord(c)&255, b64decode(s.encode('utf-8')).decode('utf-8'))), -zlib.MAX_WBITS) else: raise PBinCLIException('Unknown compression type provided in paste!') @@ -182,6 +182,7 @@ class Paste: cipher_message = json_decode(self.__decompress(cipher.decrypt_and_verify(cipher_text, cipher_tag)).decode()) self._text = cipher_message['paste'].encode() + if 'attachment' in cipher_message and 'attachment_name' in cipher_message: self._attachment = cipher_message['attachment'] self._attachment_name = cipher_message['attachment_name'] @@ -197,6 +198,7 @@ class Paste: text = SJCL().decrypt(cipher_text, password) if len(text): + if self._debug: print("Decoded Text:\t{}\n".format(text)) self._text = self.__decompress(text.decode()) if 'attachment' in self._data and 'attachmentname' in self._data: