diff --git a/onionr/communicator.py b/onionr/communicator.py index 74355c0e..2c66e2ac 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -517,7 +517,7 @@ class OnionrCommunicate: ''' if isThread: self.processBlocksThreads += 1 - for i in self._core.getBlockList(unsaved=True).split("\n"): + for i in self._core.getBlockList(unsaved = True): if i != "": if i in self.blocksProcessing or i in self.ignoredHashes: #logger.debug('already processing ' + i) @@ -553,13 +553,13 @@ class OnionrCommunicate: pass try: #blockMetadata = json.loads(self._core.getData(i)).split('}')[0] + '}' - blockMetadata = json.loads(blockContent[:blockContent.rfind(b'}') + 1].decode()) + blockMetadata = json.loads(blockContent[:blockContent.find(b'\n')].decode()) try: blockMeta2 = json.loads(blockMetadata['meta']) except KeyError: blockMeta2 = {'type': ''} pass - blockContent = blockContent[blockContent.rfind(b'}') + 1:] + blockContent = blockContent[blockContent.find(b'\n') + 1:] try: blockContent = blockContent.decode() except AttributeError: diff --git a/onionr/core.py b/onionr/core.py index 534a2c03..7877c849 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -678,7 +678,7 @@ class Core: signature = '' if sign: - signature = self._crypto.edSign(metadata + data, self._crypto.privKey, encodeResult=True) + signature = self._crypto.edSign(metadata + b'\n' + data, self._crypto.privKey, encodeResult=True) ourID = self._crypto.pubKeyHashID() # Convert from bytes on some py versions? try: @@ -692,7 +692,7 @@ class Core: if len(data) == 0: logger.error('Will not insert empty block') else: - addedHash = self.setData(metadata + data) + addedHash = self.setData(metadata + b'\n' + data) self.addToBlockDB(addedHash, selfInsert=True) self.setBlockType(addedHash, header) retData = addedHash diff --git a/onionr/onionrutils.py b/onionr/onionrutils.py index adc10d34..5c3e59f0 100644 --- a/onionr/onionrutils.py +++ b/onionr/onionrutils.py @@ -334,7 +334,7 @@ class OnionrUtils: ''' Find, decrypt, and return array of PMs (array of dictionary, {from, text}) ''' - #blocks = self._core.getBlockList().split('\n') + #blocks = self._core.getBlockList() blocks = self._core.getBlocksByType('pm') message = '' sender = '' @@ -344,8 +344,8 @@ class OnionrUtils: try: with open('data/blocks/' + i + '.dat', 'r') as potentialMessage: potentialMessage = potentialMessage.read() - blockMetadata = json.loads(potentialMessage[:potentialMessage.rfind('}') + 1]) - blockContent = potentialMessage[potentialMessage.rfind('}') + 1:] + blockMetadata = json.loads(potentialMessage[:potentialMessage.find('\n')]) + blockContent = potentialMessage[potentialMessage.find('\n') + 1:] try: message = self._core._crypto.pubKeyDecrypt(blockContent, encodedData=True, anonymous=True)