mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
zcommand: Raise error when command doesn't begin with a slash.
This commit is contained in:
@@ -6,7 +6,9 @@ from zerver.lib.actions import do_set_user_display_setting
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
|
||||
def process_zcommands(content: str, user_profile: UserProfile) -> Dict[str, Any]:
|
||||
command = content.replace('/', '')
|
||||
if not content.startswith('/'):
|
||||
raise JsonableError(_('There should be a leading slash in the zcommand.'))
|
||||
command = content[1:]
|
||||
|
||||
if command == 'ping':
|
||||
ret = dict() # type: Dict[str, Any]
|
||||
|
||||
@@ -13,6 +13,10 @@ class ZcommandTest(ZulipTestCase):
|
||||
result = self.client_post("/json/zcommand", payload)
|
||||
self.assert_json_error(result, "No such command: boil-ocean")
|
||||
|
||||
payload = dict(command="boil-ocean")
|
||||
result = self.client_post("/json/zcommand", payload)
|
||||
self.assert_json_error(result, "There should be a leading slash in the zcommand.")
|
||||
|
||||
def test_ping_zcommand(self) -> None:
|
||||
self.login(self.example_email("hamlet"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user