Browse Source

Update function in map iterator

Fixes #14.
Thanks to @mqus for solution.
Taken from https://github.com/PrivateBin/PrivateBin/pull/193#issuecomment-480262590
pull/16/head
R4SAS 5 years ago
parent
commit
8aea956e77
  1. 4
      pbincli/format.py

4
pbincli/format.py

@ -141,7 +141,7 @@ class Paste:
# nothing to do, just return original data # nothing to do, just return original data
return s return s
elif self._version == 1: 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: else:
raise PBinCLIException('Unknown compression type provided in paste!') 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()) cipher_message = json_decode(self.__decompress(cipher.decrypt_and_verify(cipher_text, cipher_tag)).decode())
self._text = cipher_message['paste'].encode() self._text = cipher_message['paste'].encode()
if 'attachment' in cipher_message and 'attachment_name' in cipher_message: if 'attachment' in cipher_message and 'attachment_name' in cipher_message:
self._attachment = cipher_message['attachment'] self._attachment = cipher_message['attachment']
self._attachment_name = cipher_message['attachment_name'] self._attachment_name = cipher_message['attachment_name']
@ -197,6 +198,7 @@ class Paste:
text = SJCL().decrypt(cipher_text, password) text = SJCL().decrypt(cipher_text, password)
if len(text): if len(text):
if self._debug: print("Decoded Text:\t{}\n".format(text))
self._text = self.__decompress(text.decode()) self._text = self.__decompress(text.decode())
if 'attachment' in self._data and 'attachmentname' in self._data: if 'attachment' in self._data and 'attachmentname' in self._data:

Loading…
Cancel
Save