emoji: Use path converter for emoji name in URL.

If the emoji name contains forward slashes, the `str` converter
would treat it as a URL delimiter. Instead use the path converter, so
that forward slashes are included in the emoji name variable.

Fixes #22377
This commit is contained in:
Ganesh Pawar 2022-07-14 12:12:05 +05:30 committed by Tim Abbott
parent f53b5274e5
commit 135854db97
2 changed files with 13 additions and 1 deletions

View File

@ -123,6 +123,18 @@ class RealmEmojiTest(ZulipTestCase):
"Emoji names must contain only numbers, lowercase English letters, spaces, dashes, underscores, and periods.",
)
def test_forward_slash_exception(self) -> None:
self.login("iago")
with get_test_image_file("img.png") as fp1:
emoji_data = {"f1": fp1}
result = self.client_post(
"/json/realm/emoji/my/emoji/with/forward/slash/", info=emoji_data
)
self.assert_json_error(
result,
"Emoji names must contain only numbers, lowercase English letters, spaces, dashes, underscores, and periods.",
)
def test_upload_uppercase_exception(self) -> None:
self.login("iago")
with get_test_image_file("img.png") as fp1:

View File

@ -258,7 +258,7 @@ v1_api_and_json_patterns = [
# realm/emoji -> zerver.views.realm_emoji
rest_path("realm/emoji", GET=list_emoji),
rest_path(
"realm/emoji/<emoji_name>",
"realm/emoji/<path:emoji_name>",
POST=upload_emoji,
DELETE=(delete_emoji, {"intentionally_undocumented"}),
),