Merge pull request #14 from lbryio/alteration-fix

formatting & prevents comment from being altered
This commit is contained in:
Oleg Silkin 2019-09-06 11:43:02 -04:00 committed by GitHub
commit 46b2238838
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View file

@ -3,16 +3,15 @@ import sqlite3
from asyncio import coroutine
from src.database.queries import hide_comments_by_id
from src.database.queries import delete_comment_by_id
from src.database.queries import get_comment_or_none
from src.database.queries import insert_comment
from src.database.queries import insert_channel
from src.database.queries import get_claim_ids_from_comment_ids
from src.server.misc import validate_signature_from_claim
from src.database.queries import get_comment_or_none
from src.database.queries import hide_comments_by_id
from src.database.queries import insert_channel
from src.database.queries import insert_comment
from src.server.misc import channel_matches_pattern_or_error
from src.server.misc import get_claim_from_id
from src.server.misc import validate_signature_from_claim
logger = logging.getLogger(__name__)
@ -22,8 +21,13 @@ def create_comment_or_error(conn, comment, claim_id, channel_id=None, channel_na
if channel_id or channel_name or signature or signing_ts:
insert_channel_or_error(conn, channel_name, channel_id)
comment_id = insert_comment(
conn=conn, comment=comment, claim_id=claim_id, channel_id=channel_id,
signature=signature, parent_id=parent_id, signing_ts=signing_ts
conn=conn,
comment=comment,
claim_id=claim_id,
channel_id=channel_id,
signature=signature,
parent_id=parent_id,
signing_ts=signing_ts
)
return get_comment_or_none(conn, comment_id)

View file

@ -1,19 +1,18 @@
import binascii
import hashlib
import logging
import re
from json import JSONDecodeError
import hashlib
import aiohttp
import ecdsa
from aiohttp import ClientConnectorError
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.serialization import load_der_public_key
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives.serialization import load_der_public_key
logger = logging.getLogger(__name__)
@ -130,7 +129,7 @@ def validate_signature_from_claim(claim, signature, signing_ts, data: str):
def clean_input_params(kwargs: dict):
for k, v in kwargs.items():
if type(v) is str:
if type(v) is str and k is not 'comment':
kwargs[k] = v.strip()
if k in ID_LIST:
kwargs[k] = v.lower()