Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#28204 closed Bug (fixed)

MultipleObjectMixin.paginate_queryset() crashes with UnicodeDecodeError if InvalidPage message contains non-ASCII

Reported by: Andrew Owned by: nobody
Component: Generic views Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Andrew)

In Django 1.11.1 in function (django.views.generic.list.py): paginate_queryset

            try:
                page = paginator.page(page_number)
                return (paginator, page, page.object_list, page.has_other_pages())
            except InvalidPage as e:
                raise Http404(_('Invalid page (%(page_number)s): %(message)s') % {
                    'page_number': page_number,
                    'message': str(e)

line 'message': str(e) contains mistake. Maybe use force_text instead of str
We have UnicodeDecodeError when non English locale:

EmptyPage(u'\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432',)

Regression in 6bd61194d49219276275542662e2fbe690534555

Attachments (1)

fix.patch (837 bytes ) - added by Andrew 8 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Andrew, 8 years ago

Component: UncategorizedGeneric views
Easy pickings: set
Type: UncategorizedBug

by Andrew, 8 years ago

Attachment: fix.patch added

comment:2 by Andrew, 8 years ago

Has patch: set
Needs tests: set

comment:4 by Andrew, 8 years ago

Description: modified (diff)

comment:5 by Tim Graham, 8 years ago

Easy pickings: unset
Summary: UnicodeDecodeError in paginate_querysetMultipleObjectMixin,paginate_queryset() crashes with UnicodeDecodeError if InvalidPage message contains non-ASCII
Triage Stage: UnreviewedAccepted

After adding a test, you can send a pull request to the stable/1.11.x branch since master doesn't support Python 2 and is thus unaffected as far as I understand.

comment:6 by Tim Graham, 8 years ago

Needs tests: unset
Summary: MultipleObjectMixin,paginate_queryset() crashes with UnicodeDecodeError if InvalidPage message contains non-ASCIIMultipleObjectMixin.paginate_queryset() crashes with UnicodeDecodeError if InvalidPage message contains non-ASCII

comment:7 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In c3418033:

[1.11.x] Fixed #28204 -- Fixed MultipleObjectMixin.paginate_queryset() crash on Python 2 if InvalidPage message contains non-ASCII.

comment:8 by Tim Graham <timograham@…>, 8 years ago

In e84034b:

Refs #28204 - Forwardported 1.11.2 release note.

Note: See TracTickets for help on using tickets.
Back to Top