Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_download():
assert demoji.download_codes() is None
assert type(demoji._EMOJI_PAT) == type(re.compile("")) # noqa
assert isinstance(demoji._CODE_TO_DESC, dict)
assert os.path.isfile(demoji.CACHEPATH)
import base64
import html
import re
from datetime import timedelta, datetime
import demoji
import pytz
from django_logs.emoji import EMOJI_LIST, EMOJI_REGEX, UNICODE_LIST
if not demoji.last_downloaded_timestamp() or datetime.now(pytz.UTC) > \
(demoji.last_downloaded_timestamp() + timedelta(days=7)):
demoji.download_codes()
if not demoji._EMOJI_PAT:
demoji.set_emoji_pattern()
def format_content_html(content: str, users: dict = None, masked_links: bool = False, newlines: bool = True) -> str:
# HTML-encode content
def encode_codeblock(m):
encoded = base64.b64encode(m.group(1).encode()).decode()
return '\x1AM' + encoded + '\x1AM'
# Encode multiline codeblocks (```text```)
content = re.sub(r'```+((?:[^`]*?\n)?(?:[\s\S]+))\n?```+', encode_codeblock, content)
# Encode links
if masked_links:
def encode_link(m):