From 58d28eed5d7886bb2b01c6bb2dc52d17fba17f28 Mon Sep 17 00:00:00 2001 From: overide Date: Tue, 5 Mar 2019 12:48:59 +0530 Subject: [PATCH] markdown: Fix emojis not rendering with :bogus: in the line. This fixes an issue where invalid emoji name prevents following emojis from rendering. This reverts the code change in 88423496294cf6c01ecc258acf01a203f600d570, while still passing the tests added in that commit (it seems the original commit had misdiagnosed an ordering bug and thus introduced this issue). Fixes: #11770. --- zerver/lib/bugdown/__init__.py | 2 +- zerver/tests/fixtures/markdown_test_cases.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 6a3c12df95..5fe56ae7bb 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -1179,7 +1179,7 @@ class Emoji(markdown.inlinepatterns.Pattern): elif name in name_to_codepoint: return make_emoji(name_to_codepoint[name], orig_syntax) else: - return None + return orig_syntax def content_has_emoji_syntax(content: str) -> bool: return re.search(EMOJI_REGEX, content) is not None diff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.json index 741a1b4adc..00f6006f3e 100644 --- a/zerver/tests/fixtures/markdown_test_cases.json +++ b/zerver/tests/fixtures/markdown_test_cases.json @@ -542,6 +542,11 @@ "expected_output": "

Emojis like :man-girl-girl: which have ZWJ are banned for now.

", "text_content": "Emojis like :man-girl-girl: which have ZWJ are banned for now." }, + { + "name": "valid_emoji_preceded_by_invalid_emoji", + "input": "This is :invalidemoji: which should not prevent rendering :smile:", + "expected_output": "

This is :invalidemoji: which should not prevent rendering :smile:

" + }, { "name": "safe_html", "input": "

stay normal

thanks",