#28796: django.utils.http.urlsafe_base64_encode() broken in Django 2.0
---------------------------+--------------------------------------
     Reporter:  Nick       |                    Owner:  nobody
         Type:  Bug        |                   Status:  new
    Component:  Utilities  |                  Version:  2.0
     Severity:  Normal     |               Resolution:
     Keywords:             |             Triage Stage:  Unreviewed
    Has patch:  0          |      Needs documentation:  0
  Needs tests:  0          |  Patch needs improvement:  0
Easy pickings:  0          |                    UI/UX:  0
---------------------------+--------------------------------------
Description changed by Nick:

Old description:

> Suppose we have:
>
> hashed_msg = hmac.new(key, msg=message, digestmod=sha384)
> url = urlsafe_base64_encode(hashed.digest())
>
> Now url is a bytes object, say b'asdfwerqwefa'. In django 1.11, bytes-
> like objects could be placed in urls no problem, creating (say)
> localhost:8000/asdfwerqwefa
>
> However, in django 2.0, the url becomes (say)
>
> localhost:8000/b'asdfwerqwefa'
>
> which seems less 'urlsafe', as the quotes and the 'b' are added into the
> url. Shouldn't urlsafe_base64_encode now return a string, if bytes in
> urls now retain the quotes?
>
> I have created a full project which reproduces the bug here:
>
> https://github.com/NAThompson/urlsafe_bug
>
> To reproduce the bug, type:
>
> $ ./manage.py shell
> >>> import reproduce

New description:

 Suppose we have:

 hashed_msg = hmac.new(key, msg=message, digestmod=sha384)
 url = urlsafe_base64_encode(hashed.digest())

 Now url is a bytes object, say b'asdfwerqwefa'. In django 1.11, bytes-like
 objects could be placed in urls no problem, creating (say)
 localhost:8000/asdfwerqwefa

 However, in django 2.0, the url becomes (say)

 localhost:8000/b'asdfwerqwefa'

 which seems less 'urlsafe', as the quotes and the 'b' are added into the
 url. Shouldn't urlsafe_base64_encode now return a string, if bytes in urls
 now retain the quotes?

 I have created a full project which reproduces the bug here:

 https://github.com/NAThompson/urlsafe_bug

 To reproduce the bug, type:

 $ ./manage.py shell
 >>> import reproduce


 This bug is present in commit d90936f41a2d7a3361e51fc49be033ba0f05f458,
 but much before that the 'django.urls.path' doesn't exist, so bisection
 doesn't work cleanly.

--

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.aad13d55036c456518cdc0dffe63a94d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to