From d9b9f596d3ebf17e39d53f593c940a95ce8cfa20 Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Tue, 22 Nov 2022 19:15:27 +0100 Subject: [PATCH] Skip custom emojis which don't match emoji regexp Otherwise, emojis containing forbidden symbols (for example, `-`) appear in "emoji selector" on admin/new page, but are not replaced with emoji image on submit. Also add a note to documentation mentioning allowed characters. --- app/utils/emoji.py | 2 ++ docs/user_guide.md | 1 + 2 files changed, 3 insertions(+) diff --git a/app/utils/emoji.py b/app/utils/emoji.py index 0fcf6bc..e533bae 100644 --- a/app/utils/emoji.py +++ b/app/utils/emoji.py @@ -23,6 +23,8 @@ def _load_emojis(root_dir: Path, base_url: str) -> None: mt = mimetypes.guess_type(emoji.name)[0] if mt and mt.startswith("image/"): name = emoji.name.split(".")[0] + if not re.match(EMOJI_REGEX, f':{name}:'): + continue ap_emoji: "RawObject" = { "type": "Emoji", "name": f":{name}:", diff --git a/docs/user_guide.md b/docs/user_guide.md index 96d9836..ec398f3 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -113,6 +113,7 @@ You can copy/paste them from [getemoji.com](https://getemoji.com/). #### Custom emoji You can add custom emoji in the `data/custom_emoji` directory and they will be picked automatically. +Do not use exotic characters in filename - only letters, numbers, and underscore symbol `_` are allowed. #### Custom CSS