Opened 5 years ago
Last modified 5 years ago
#31605 closed Bug
messages shortcuts will not process with whitespace — at Version 1
Reported by: | Rory Patrick Sheridan | Owned by: | nobody |
---|---|---|---|
Component: | contrib.messages | Version: | 3.0 |
Severity: | Normal | Keywords: | messages, shortcuts, cookies, success, error, bug, message |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
When using:
messages.success(request, 'str')
or other shortcuts, messages that contain any whitespace do not show. A message that is a single string of characters with no whitespace such as "thisisanexample" will display, however "this is an example" or even " " will not be displayed on the page.
The cookie data is processed by the backend, as it can be seen in the cookies, but it is never read when parsing the page templates.
{% if messages %} returns False, so it isn't being read at all.
The exact same code but with no whitespace results in functionality.
I have tested it on Chrome and Chrome Android and it is the same on both devices.
I have tested it using tutorial code as well.
I have reproduced it using django 2.2.12, with the same browser versions, Stable Chrome builds.
I haven't tested other methods of displaying messages outside of shortcuts.
my relevant code:
def post_add(request): next = request.GET.get('next', '') if request.method == 'POST': form = PostForm(request.POST) if form.is_valid(): form.save() messages.success(request, 'This is an example') return HttpResponseRedirect(next) else: form = PostForm() return HttpResponseRedirect(next)
Cookie data examples here:
"44cb14ea2f1cade16b5dad1524386ff0ef096317$[[\"__json_message\"\0540\05440\054\"This is an example\"]]" "2c19fe90a788435e86265a97348ae12eac4780d8$[[\"__json_message\"\0540\05425\054\"This is an example\"]]"
Change History (2)
by , 5 years ago
Attachment: | Screenshot 2020-05-19 at 02.59.53.2.png added |
---|
comment:1 by , 5 years ago
Description: | modified (diff) |
---|
Shows that the message fires if there is no whitespace in the string