﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28796	django.utils.http.urlsafe_base64_encode() broken in Django 2.0	Nick	nobody	"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&#39;asdfwerqwefa&#39;

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

"	Bug	new	Utilities	2.0	Normal			nathompson7@…	Unreviewed	0	0	0	0	0	0
