mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Fix 1.3 compat issue. Closes #780
This commit is contained in:
parent
c2280e34ec
commit
3f91379e4e
|
@ -400,12 +400,16 @@ except ImportError:
|
|||
try:
|
||||
from django.utils.html import smart_urlquote
|
||||
except ImportError:
|
||||
import re
|
||||
from django.utils.encoding import smart_str
|
||||
try:
|
||||
from urllib.parse import quote, urlsplit, urlunsplit
|
||||
except ImportError: # Python 2
|
||||
from urllib import quote
|
||||
from urlparse import urlsplit, urlunsplit
|
||||
|
||||
unquoted_percents_re = re.compile(r'%(?![0-9A-Fa-f]{2})')
|
||||
|
||||
def smart_urlquote(url):
|
||||
"Quotes a URL if it isn't already quoted."
|
||||
# Handle IDN before quoting.
|
||||
|
@ -421,7 +425,7 @@ except ImportError:
|
|||
# contains a % not followed by two hexadecimal digits. See #9655.
|
||||
if '%' not in url or unquoted_percents_re.search(url):
|
||||
# See http://bugs.python.org/issue2637
|
||||
url = quote(force_bytes(url), safe=b'!*\'();:@&=+$,/?#[]~')
|
||||
url = quote(smart_str(url), safe=b'!*\'();:@&=+$,/?#[]~')
|
||||
|
||||
return force_text(url)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user