[Django] #23333: urlsafe_base64_encode/decode don't round-trip on python3

48 views
Skip to first unread message

Django

unread,
Aug 21, 2014, 10:23:44 AM8/21/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
----------------------------+--------------------
Reporter: Ian-Foote | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
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 [https://github.com/Ian-Foote/django/tree/urlsafe_base64 github
branch].

--
Ticket URL: <https://code.djangoproject.com/ticket/23333>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 22, 2014, 3:18:33 AM8/22/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
---------------------------+------------------------------------

Reporter: Ian-Foote | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+------------------------------------
Changes (by claudep):

* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/23333#comment:1>

Django

unread,
Aug 22, 2014, 4:04:19 AM8/22/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
---------------------------+------------------------------------

Reporter: Ian-Foote | Owner: nobody
Type: Bug | Status: new
Component: Utilities | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+------------------------------------

Comment (by Ian-Foote):

I've updated my branch with your suggested fix and created a
[https://github.com/django/django/pull/3099 pull request].

--
Ticket URL: <https://code.djangoproject.com/ticket/23333#comment:2>

Django

unread,
Aug 22, 2014, 7:36:54 AM8/22/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
---------------------------+-------------------------------------
Reporter: Ian-Foote | Owner: Ian-Foote
Type: Bug | Status: assigned
Component: Utilities | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+-------------------------------------
Changes (by Ian-Foote):

* owner: nobody => Ian-Foote
* status: new => assigned
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/23333#comment:3>

Django

unread,
Aug 22, 2014, 8:11:42 PM8/22/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
---------------------------+-------------------------------------
Reporter: Ian-Foote | Owner: Ian-Foote
Type: Bug | Status: closed
Component: Utilities | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"03d89168a27f7c5a8fb4b466170c997aca5fdf02"]:
{{{
#!CommitTicketReference repository=""
revision="03d89168a27f7c5a8fb4b466170c997aca5fdf02"
Fixed #23333 -- Made urlsafe_base64_decode() return proper type on Python
3.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23333#comment:4>

Django

unread,
Oct 8, 2014, 12:31:57 PM10/8/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
---------------------------+-------------------------------------
Reporter: Ian-Foote | Owner: Ian-Foote
Type: Bug | Status: closed
Component: Utilities | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+-------------------------------------

Comment (by Ian-Foote):

Can this fix be backported to 1.6 and 1.7?

--
Ticket URL: <https://code.djangoproject.com/ticket/23333#comment:5>

Django

unread,
Oct 8, 2014, 1:57:20 PM10/8/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
---------------------------+-------------------------------------
Reporter: Ian-Foote | Owner: Ian-Foote
Type: Bug | Status: closed
Component: Utilities | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+-------------------------------------

Comment (by timgraham):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/23333#comment:6>

Django

unread,
Oct 8, 2014, 2:04:29 PM10/8/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
---------------------------+-------------------------------------
Reporter: Ian-Foote | Owner: Ian-Foote
Type: Bug | Status: closed
Component: Utilities | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"d8306650071369ee9d7cad71120d13c22e900a10"]:
{{{
#!CommitTicketReference repository=""
revision="d8306650071369ee9d7cad71120d13c22e900a10"
[1.7.x] Fixed #23333 -- Made urlsafe_base64_decode() return proper type on
Python 3.

Backport of 03d89168a2 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23333#comment:7>

Django

unread,
Oct 8, 2014, 2:06:50 PM10/8/14
to django-...@googlegroups.com
#23333: urlsafe_base64_encode/decode don't round-trip on python3
---------------------------+-------------------------------------
Reporter: Ian-Foote | Owner: Ian-Foote
Type: Bug | Status: closed
Component: Utilities | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"9e2e4cb6dda5fa1d4d6b047adbcc215daf4d6ff1"]:
{{{
#!CommitTicketReference repository=""
revision="9e2e4cb6dda5fa1d4d6b047adbcc215daf4d6ff1"
Added 1.7.1 release notes for refs #23333.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23333#comment:8>

Reply all
Reply to author
Forward
0 new messages