fixed null claim name support for postgres
This commit is contained in:
parent
81926a42f9
commit
635aebfeeb
3 changed files with 14 additions and 14 deletions
|
@ -383,31 +383,24 @@ class BulkLoader:
|
|||
row['claim_id'] = txo.claim_id
|
||||
row['claim_hash'] = txo.claim_hash
|
||||
try:
|
||||
claim_name = txo.claim_name
|
||||
if '\x00' in claim_name:
|
||||
# log.error(f"Name for claim {txo.claim_id} contains a NULL (\\x00) character, skipping.")
|
||||
pass
|
||||
else:
|
||||
row['claim_name'] = claim_name
|
||||
row['claim_name'] = txo.claim_name.replace('\x00', '')
|
||||
except UnicodeDecodeError:
|
||||
# log.error(f"Name for claim {txo.claim_id} contains invalid unicode, skipping.")
|
||||
pass
|
||||
return row
|
||||
|
||||
def claim_to_rows(self, txo: Output) -> Tuple[dict, List]:
|
||||
try:
|
||||
assert txo.claim_name
|
||||
assert txo.normalized_name
|
||||
except Exception:
|
||||
#self.logger.exception(f"Could not decode claim name for {tx.id}:{txo.position}.")
|
||||
claim_name = txo.claim_name.replace('\x00', '')
|
||||
normalized_name = txo.normalized_name
|
||||
except UnicodeDecodeError:
|
||||
return {}, []
|
||||
tx = txo.tx_ref.tx
|
||||
claim_hash = txo.claim_hash
|
||||
claim_record = {
|
||||
'claim_hash': claim_hash,
|
||||
'claim_id': txo.claim_id,
|
||||
'claim_name': txo.claim_name,
|
||||
'normalized': txo.normalized_name,
|
||||
'claim_name': claim_name,
|
||||
'normalized': normalized_name,
|
||||
'address': txo.get_address(self.ledger),
|
||||
'txo_hash': txo.ref.hash,
|
||||
'amount': txo.amount,
|
||||
|
|
|
@ -44,7 +44,7 @@ URL_REGEX = _create_url_regex()
|
|||
|
||||
|
||||
def normalize_name(name):
|
||||
return unicodedata.normalize('NFD', name).casefold()
|
||||
return unicodedata.normalize('NFD', name).casefold().replace('\x00', '')
|
||||
|
||||
|
||||
class PathSegment(NamedTuple):
|
||||
|
|
|
@ -11,6 +11,7 @@ from lbry import Config, Database, RegTestLedger, Transaction, Output, Input
|
|||
from lbry.crypto.base58 import Base58
|
||||
from lbry.schema.claim import Stream, Channel
|
||||
from lbry.schema.support import Support
|
||||
from lbry.blockchain.script import OutputScript
|
||||
from lbry.blockchain.lbrycrd import Lbrycrd
|
||||
from lbry.blockchain.sync import BlockchainSync
|
||||
from lbry.blockchain.dewies import dewies_to_lbc, lbc_to_dewies
|
||||
|
@ -690,6 +691,12 @@ class TestGeneralBlockchainSync(SyncingBlockchainTestCase):
|
|||
claims = await search()
|
||||
self.assertEqual(0, len(claims))
|
||||
|
||||
async def test_null_claim_name(self):
|
||||
await self.create_claim(name='\x00')
|
||||
await self.generate(1)
|
||||
empty_name, = await self.db.search_claims()
|
||||
self.assertEqual('', empty_name.normalized_name)
|
||||
|
||||
async def test_short_and_canonical_urls(self):
|
||||
search = self.db.search_claims
|
||||
|
||||
|
|
Loading…
Reference in a new issue