Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23333 closed Bug (fixed)

urlsafe_base64_encode/decode don't round-trip on python3

Reported by: Ian Foote Owned by: Ian Foote
Component: Utilities Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The functions urlsafe_base64_encode and urlsafe_base64_decode in django.utils.http should be inverses of each other, but on python3 urlsafe_base64_encode returns bytes but urlsafe_base64_decode expects a str. I've created a test for this on a github branch.

Change History (8)

comment:1 by Claude Paroz, 10 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

Confirmed. The solution is probably to use django.utils.encoding.force_bytes instead of calling encode directly.

comment:2 by Ian Foote, 10 years ago

I've updated my branch with your suggested fix and created a pull request.

comment:3 by Ian Foote, 10 years ago

Has patch: set
Owner: changed from nobody to Ian Foote
Status: newassigned

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

Resolution: fixed
Status: assignedclosed

In 03d89168a27f7c5a8fb4b466170c997aca5fdf02:

Fixed #23333 -- Made urlsafe_base64_decode() return proper type on Python 3.

comment:5 by Ian Foote, 10 years ago

Can this fix be backported to 1.6 and 1.7?

comment:6 by Tim Graham, 10 years ago

As a bug in a new feature in 1.6, yes. However, after the release of 1.7, 1.6 is only receiving security fixes so I think we should do 1.7 only.

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

In d8306650071369ee9d7cad71120d13c22e900a10:

[1.7.x] Fixed #23333 -- Made urlsafe_base64_decode() return proper type on Python 3.

Backport of 03d89168a2 from master

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

In 9e2e4cb6dda5fa1d4d6b047adbcc215daf4d6ff1:

Added 1.7.1 release notes for refs #23333.

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