From 2495df885932b7261e3f62439a14cd5ee3fd54fd Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sat, 27 Jun 2020 23:14:28 -0400 Subject: [PATCH] null in claim description --- lbry/db/query_context.py | 6 +++--- lbry/schema/tags.py | 6 +++++- tests/unit/schema/test_tags.py | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lbry/db/query_context.py b/lbry/db/query_context.py index 6a1e2c9b8..0c15cfc8f 100644 --- a/lbry/db/query_context.py +++ b/lbry/db/query_context.py @@ -436,9 +436,9 @@ class BulkLoader: claim_record['claim_type'] = TXO_TYPES['stream'] claim_record['stream_type'] = STREAM_TYPES[guess_stream_type(claim_record['media_type'])] claim_record['media_type'] = claim.stream.source.media_type - claim_record['title'] = claim.stream.title - claim_record['description'] = claim.stream.description - claim_record['author'] = claim.stream.author + claim_record['title'] = claim.stream.title.replace('\x00', '') + claim_record['description'] = claim.stream.description.replace('\x00', '') + claim_record['author'] = claim.stream.author.replace('\x00', '') if claim.stream.video and claim.stream.video.duration: claim_record['duration'] = claim.stream.video.duration if claim.stream.audio and claim.stream.audio.duration: diff --git a/lbry/schema/tags.py b/lbry/schema/tags.py index 2d3cf79bc..049f611ae 100644 --- a/lbry/schema/tags.py +++ b/lbry/schema/tags.py @@ -6,7 +6,11 @@ WEIRD_CHARS_RE = re.compile(r"[#!~]") def normalize_tag(tag: str): - return MULTI_SPACE_RE.sub(' ', WEIRD_CHARS_RE.sub(' ', tag.lower().replace("'", ""))).strip() + return MULTI_SPACE_RE.sub( + ' ', WEIRD_CHARS_RE.sub( + ' ', tag.lower().replace("'", "").replace('\x00', '') + ) + ).strip() def clean_tags(tags: List[str]): diff --git a/tests/unit/schema/test_tags.py b/tests/unit/schema/test_tags.py index 4dd637a29..a54aba80d 100644 --- a/tests/unit/schema/test_tags.py +++ b/tests/unit/schema/test_tags.py @@ -14,6 +14,7 @@ class TestTagNormalization(unittest.TestCase): tag('tag', 'T\'ag') tag('t ag', '\tT \nAG ') tag('tag hash', '#tag~#hash!') + tag('foobar', 'foo\x00bar') def test_clean_tags(self): self.assertEqual(['tag'], clean_tags([' \t #!~', '!taG', '\t']))