From 8c91c91d865e431a94dc93f1a5df52e96a26bece Mon Sep 17 00:00:00 2001 From: N-Shar-ma Date: Tue, 5 Sep 2023 22:55:40 +0530 Subject: [PATCH] widgets: Fix bug where a new line right after /todo broke rendering. When there was no space right after `/todo` but there was content on a new line, the message would be rendered plainly, not as a todo widget. This was because we split on only the space character to then check if the first token was a valid widget. Now we split on both spaces and newlines to extract the widget name, irrespective of whether it is followed by a space or a newline. This results in the message being rendered as a todo widget as expected. --- zerver/lib/widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zerver/lib/widget.py b/zerver/lib/widget.py index 2eabedf08c..e8abb15649 100644 --- a/zerver/lib/widget.py +++ b/zerver/lib/widget.py @@ -8,7 +8,7 @@ from zerver.models import Message, SubMessage def get_widget_data(content: str) -> Tuple[Optional[str], Optional[str]]: valid_widget_types = ["poll", "todo"] - tokens = content.split(" ") + tokens = re.split(r"\s+|\n+", content) # tokens[0] will always exist if tokens[0].startswith("/"):